Commit Graph
100 Commits
Author SHA1 Message Date
Feoramund c4f6e973d9 mem: Don't change Scratch_Allocator's backup allocator
The backup allocator is set at `init` and must stay the same for the
lifetime of the Scratch allocator, as this allocator is used to free all
`leaked_allocations`. Changing it could lead to a situation where the
wrong allocator is used to free a leaked allocation.
2025-06-14 13:21:14 -04:00
Feoramund 62b0f71768 mem: Fix comment typo 2025-06-14 13:21:14 -04:00
Feoramund 890245c229 mem: Don't unpoison the header of a Stack allocation 2025-06-14 13:21:14 -04:00
Feoramund 79e5ddaa26 mem: Make stack_resize* free if size is 0
This will cause an error if the memory being resized was not the last
allocation, as should be expected according to the description that this
"acts just like stack_free."
2025-06-14 13:21:14 -04:00
Feoramund 179a8559f6 mem: Add guards against buggy allocators overlapping allocations 2025-06-14 13:21:14 -04:00
Feoramund f627b55cf5 mem: Fix several issues in Scratch_Allocator
1. The size was being adjusted for the alignment which does not make any
   sense without the context of the base pointer. Now we just add the
   `alignment - 1` to the size if needed then adjust the pointer.

2. The root pointer of the last allocation is now stored in order to
   make the free operation more useful (and to cover the right memory
   region for ASan).

3. Resizing now only works on the last allocation instead of any address
   in a valid range, which resulted in overwriting allocations that had
   just been made.

4. `old_memory` is now re-poisoned entirely before the resized range is
   returned with the new range unpoisoned. This will guarantee that
   there are no unpoisoned gaps.

Fixes #2694
2025-06-14 12:35:16 -04:00
Feoramund 61f9fb7232 runtime: Remove unneeded max(0, ...)
`len` never returns negative numbers, so this was an overcautious
expression.
2025-06-13 12:09:10 -04:00
Feoramund 23c1ce8722 container/queue: Remove trailing whitespace 2025-06-11 11:57:38 -04:00
Feoramund 66b2acbf24 container/queue: Add tests 2025-06-11 11:55:30 -04:00
Feoramund 638a1529a3 container/queue: Add shrink 2025-06-11 11:55:30 -04:00
Feoramund 040d79e1b9 container/queue: Let queues be re-initialized with different allocators 2025-06-11 11:55:30 -04:00
Feoramund 81f5763482 container/queue: Add common aliases enqueue and dequeue 2025-06-11 11:55:30 -04:00
Feoramund 6cb84e467b container/queue: Document the package 2025-06-11 11:55:30 -04:00
Feoramund 862442511a container/queue: Reorganize 2025-06-11 11:55:29 -04:00
Feoramund 58bda1209a container/queue: Deprecate peek_*
The `*_ptr` and `peek_*` procedures did the same thing, except `peek_*`
was over-cautiously putting the index through a modulo when all
assignments to `q.offset` are already wrapped.
2025-06-11 11:54:52 -04:00
Feoramund 27cd508571 container/queue: Fix and add more bounds checking 2025-06-11 11:54:47 -04:00
Feoramund 1fc390146f Let -no-entry-point work for Windows DLLs
Fixes #4660
2025-06-10 08:54:28 -04:00
Feoramund 4236b043e2 Move negation in internal_rat_to_float to end of procedure
This should cause a compiler error, due to the assignment to a named
return value in a deferred block.

Fixes #4565
2025-06-10 08:34:07 -04:00
Feoramund 5ed2735658 Guard against invalid proc types in parameter list
Fixes #4362
2025-06-10 06:13:14 -04:00
Feoramund 6dee422700 flags: Rename varg to overflow, let it be renamed with config 2025-06-09 13:02:05 -04:00
Feoramund 2e199c669f flags: Forbid combination of pos and manifold 2025-06-09 11:39:10 -04:00
Feoramund cae43b801f Add more core:flags tests to codify behavior 2025-06-09 11:39:10 -04:00
Feoramund 7c5700996f flags: Mention varg in the documentation 2025-06-09 11:39:10 -04:00
Feoramund e20db8df89 flags: Rename variadic to manifold (breaking change) 2025-06-09 11:27:27 -04:00
Feoramund 0747032e4a Use idiomatic rawptr(nil) 2025-06-08 17:48:06 -04:00
Feoramund 54f018ffc7 Guard against untyped nil in type cycle and type info sections
Fixes #5299
2025-06-08 17:48:01 -04:00
Feoramund 1cd1f9fec4 Add nullptr check in add_type_info_type_internal
Fixes #5215
2025-06-06 09:23:06 -04:00
Feoramund 2760f43ce7 Add deprecation warnings for strconv.append_* 2025-06-05 17:34:14 -04:00
Feoramund 153f7af594 Rename fixed.append to fixed.write too, for good measure 2025-06-05 16:56:29 -04:00
Feoramund 0049c62b26 Remove trailing whitespace 2025-06-05 16:56:01 -04:00
Feoramund b7de15caa3 Clarify strconv.append_* to strconv.write_* 2025-06-05 16:56:00 -04:00
Feoramund f8228a91d1 Mark some uninitialized memory as safe
Syscalls (but not C functions) are opaque to MemorySanitizer, thus some
memory addresses need to be manually marked as safe to access.
2025-06-05 16:06:44 -04:00
Feoramund 9c5640886d Add @(no_sanitize_memory) proc attribute with MSan additions to base:sanitizer 2025-06-05 16:06:40 -04:00
Feoramund 36b41ce163 Let compound literal array be broadcast to a struct field of arrays
Fixes #4364

Patch courtesy of @cribalik
2025-06-05 07:48:10 -04:00
Feoramund d046214f67 Be strict with type switch case column alignment too
This copies the same block used for regular switch cases.

Fixes #4673
2025-06-04 14:00:33 -04:00
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 91111937a7 Guard against negative index in inject_at
Fixes #4595
2025-06-04 13:58:06 -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