Compare commits

...

5080 Commits

Author SHA1 Message Date
ed ad0939009b core:thread support naming (create_ex, set_name), windows only (for now) 2025-11-06 23:36:58 -05:00
ed 50c781bd7e Merge tag 'dev-2025-11' 2025-11-05 22:27:46 -05:00
gingerBill e5153a937b Merge pull request #5859 from odin-lang/bill/change-license
Change Odin's LICENSE to zlib from BSD 3-clause
2025-11-04 13:53:13 +00:00
gingerBill fd995050dd Merge pull request #5883 from NicknEma/patch-1
Fix docs on int*_max
2025-11-04 12:14:12 +00:00
NicknEma 7317704fd0 Fix docs on int*_max 2025-11-04 13:11:48 +01:00
gingerBill 75a2aa580d Merge pull request #5879 from mtarik34b/fix-5239
`text/scanner`: Add missing switch case for octal prefix (fixes #5239)
2025-11-04 10:51:48 +00:00
gingerBill 3731cf4e08 Fix #5176 2025-11-04 10:42:24 +00:00
Jeroen van Rijn 64cf8a5eb9 Merge pull request #5880 from terids/core-darwin-bindings
core/sys/darwin/Foundation: Add additional AppKit bindings
2025-11-04 10:59:38 +01:00
Glenn 2951e51487 Add comma to last enums to fix build check 2025-11-03 23:16:25 +00:00
Glenn 4485a45866 Add Window_center 2025-11-03 23:05:26 +00:00
Glenn 65ee1339b9 Add View alloc 2025-11-03 23:03:33 +00:00
mtarik34b 7738f4ef9a Add missing case for octal prefix 2025-11-03 22:20:21 +01:00
Laytan a414061998 Merge pull request #5878 from laytan/fix-cbor-epoch-small-value
encoding/cbor: fix epoch tag with small values
2025-11-03 20:42:10 +01:00
Laytan 9893a0eaea encoding/cbor: fix epoch tag with small values 2025-11-03 20:33:17 +01:00
Glenn 332653ca24 Add additional window bindings 2025-11-03 18:06:43 +00:00
Glenn 916e8810cc Add orderFront and orderOut 2025-11-03 18:06:15 +00:00
Glenn 8b3d74f797 Add getter for the WindowDelegate from the Window 2025-11-03 17:54:42 +00:00
Glenn 406eb9c7f5 Add WindowCollectionBehaviour, WindowLevel, WindowTabbingMode 2025-11-03 17:28:51 +00:00
Glenn 4f939cadc3 Add RunningApplication_finishedLaunching 2025-11-03 14:29:58 +00:00
Glenn 9f78c1e7be Add Application_postEvent
https://developer.apple.com/documentation/appkit/nsapplication/postevent(_:atstart:)?language=objc
2025-11-03 14:29:58 +00:00
Glenn b4d4cd47f5 Add Event_otherEventWithType
https://developer.apple.com/documentation/appkit/nsevent/otherevent(with:location:modifierflags:timestamp:windownumber:context:subtype:data1:data2:)
2025-11-03 14:29:58 +00:00
Glenn 8c6120f414 Add Application_stop
https://developer.apple.com/documentation/appkit/nsapplication/stop(_:)?language=objc
2025-11-03 14:29:58 +00:00
Jeroen van Rijn 8a417e75b7 Add nullptr assert for #5875 2025-11-03 15:27:07 +01:00
gingerBill a08f313477 Merge pull request #5868 from mfbulut/master
Added MAX_MATERIAL_MAPS constant
2025-11-02 19:23:36 +00:00
gingerBill d8f26720bb Improve error handling for #5506 2025-11-02 15:27:33 +00:00
gingerBill 2d5b431b85 Merge branch 'master' of https://github.com/odin-lang/Odin 2025-11-02 15:21:23 +00:00
gingerBill ee36f6fe33 Fix #5506 2025-11-02 15:21:12 +00:00
gingerBill 22a82f7c88 Merge pull request #5872 from thetarnav/inject_at_soa
Add `inject_at_soa` and `append_nothing_soa` procedures
2025-11-02 15:11:02 +00:00
thetarnav 72754962ab Use resize_soa instead of resize proc group in soa procs 2025-11-02 14:20:55 +01:00
gingerBill 5d609d402f Merge pull request #5867 from BradLewis/empty-selector-fields
Parse empty idents after selector as a selector expr with an empty field
2025-11-02 12:45:37 +00:00
Jeroen van Rijn ade189008b Merge pull request #5871 from Kelimion/bug-5865
Add #subtype using to name canonicalization
2025-11-02 13:35:47 +01:00
Jeroen van Rijn b6181a768e Add space 2025-11-02 13:28:34 +01:00
Jeroen van Rijn 283b160697 Merge branch 'master' into bug-5865 2025-11-02 13:22:06 +01:00
gingerBill 7f2ab31acc Fix constant nil assignment to union of nillable types in backend 2025-11-02 12:04:21 +00:00
thetarnav e364e76f7f Add inject_at_soa and append_nothing_soa procedures 2025-11-02 12:13:11 +01:00
Jeroen van Rijn 91d923bd8f Merge pull request #5870 from thetarnav/ease-inverse
Add inverse ease procedures
2025-11-02 08:03:27 +01:00
Jeroen van Rijn 505b85ead5 Add #subtype using to name canonicalization 2025-11-02 07:45:40 +01:00
thetarnav c63ad8b1cf Cleanup ease_inverse 2025-11-01 21:22:06 +01:00
thetarnav 78f9f8bbce Add ease inverse procedures 2025-11-01 21:11:32 +01:00
Jeroen van Rijn 6ea7bdbbe5 Add ODIN_TEST_GO_TO_ERROR to print test fail locations in a manner friendly to go-to error in editors 2025-11-01 16:11:43 +01:00
Furkan 9c6885d8b5 Added MAX_MATERIAL_MAPS constant 2025-11-01 11:05:50 +03:00
Brad Lewis e2b276f3ea Parse empty idents after selector as a selector expr with an empty field 2025-11-01 01:32:46 -04:00
Jeroen van Rijn f005136592 Also disable OSC codes to update title when ODIN_TEST_FANCY=false 2025-10-31 17:39:29 +01:00
gingerBill fc5ef57a97 Document the rest of os2. 2025-10-31 16:00:44 +00:00
gingerBill d2e274f0fe Update documentation for os2 once more! 2025-10-31 15:51:36 +00:00
gingerBill da1d599326 Bodge runtime.exit for haiku 2025-10-31 15:19:08 +00:00
gingerBill 1329630bbc Improve documentation for the file based operations in os2 2025-10-31 15:17:54 +00:00
gingerBill b9df67f8c5 Change to Permissions bit_set from relying on octal numbering for os2 2025-10-31 14:45:53 +00:00
gingerBill d374dc3c99 Add os2 to examples/all 2025-10-31 14:24:19 +00:00
gingerBill 686ddbb548 use runtime.exit for os2.exit 2025-10-31 10:24:21 +00:00
gingerBill f5d080789f Fix union(T){} constant initialization 2025-10-31 09:13:10 +00:00
Jeroen van Rijn d062203ff9 Merge pull request #5863 from dan-lei/patch-1
Typo in description of mem.ptr_sub.
2025-10-30 22:24:56 +01:00
Daniel Troszczyński 5df053f765 Typo in description of mem.ptr_sub. 2025-10-30 21:04:28 +01:00
Jeroen van Rijn 338733d9ef Remove duplicate import 2025-10-30 17:54:02 +01:00
gingerBill 91a9875077 Correct cast to uintptr 2025-10-30 16:32:26 +00:00
gingerBill efb553afad Add runtime.exit 2025-10-30 16:29:23 +00:00
gingerBill 816c47058d For test runner, try to look for os.exit or os2.exit 2025-10-30 16:14:32 +00:00
Jeroen van Rijn 1a00d02ee7 Merge branch 'master' of github.com:odin-lang/Odin 2025-10-30 11:29:59 +01:00
Jeroen van Rijn 5b6889ccf5 Enable misnamed doc example test for small_array 2025-10-30 11:29:51 +01:00
gingerBill 074a8d7df5 constant_truncate -> constant_trunc to be consistent with other intrinsics 2025-10-30 09:37:09 +00:00
gingerBill 0972690e14 Add suggestion for T[] to be []T if a type is allowed in that parsing context 2025-10-30 09:16:19 +00:00
gingerBill 99520d82fd Add intrinsics.constant_(floor|truncate|ceil|round) 2025-10-30 08:52:21 +00:00
gingerBill 13ddf66cc9 Fix declaration of type_is_bit_field 2025-10-30 08:39:22 +00:00
gingerBill 36d63b14b5 Just retry again with lb_generate_missing_procedures 2025-10-29 17:46:00 +01:00
gingerBill 4bdce9bf0a Correct license for tlsf 2025-10-29 16:00:29 +00:00
gingerBill d38602e788 Merge pull request #5861 from NickDriscoll/hlsl-half
Add support for `half` types to `core:math/linalg/hlsl`
2025-10-29 10:29:07 +00:00
Jeroen van Rijn b58bb6519e Merge pull request #5860 from harold-b/hb.fix-export-link-libs-file
Fix `-export-linked-libs-file` issue where it multiple libraries in a single foreign export.
2025-10-29 09:41:02 +01:00
Nick Driscoll 5fa41f9f03 Add half support to all proc groups and add ashalf proc group 2025-10-28 21:42:08 -04:00
Nick Driscoll f3b6ad01ab Add all half scalar, vector, and matrix types 2025-10-28 21:42:08 -04:00
Harold Brenes e05c21522d Fix -export-linked-libs-file issue where it multiple libraries in a single foreign export. 2025-10-28 20:21:24 -04:00
gingerBill 50176deeba Remove unneeded newlines 2025-10-28 14:53:26 +00:00
gingerBill 68d67ce8f4 Merge branch 'master' into bill/change-license 2025-10-28 14:52:43 +00:00
gingerBill 2508b82878 Change ^i16 to cstring16 where appropriate 2025-10-28 14:50:13 +00:00
gingerBill 842cfee0f3 Change Odin's LICENSE to zlib from BSD 3-clause
This change was made in order to allow things produced with Odin and using Odin's core library, to not require the LICENSE to also be distributed alongside the binary form.
2025-10-28 14:38:25 +00:00
gingerBill d390ae2f97 Minor change to misc/shell.bat 2025-10-28 13:26:56 +00:00
gingerBill 5e528f8e97 Remove core:encoding/ini dependency in user_posix.odin 2025-10-28 13:21:35 +00:00
gingerBill 4c8f99cd36 Add #caller_location to os2.read_entire_file 2025-10-28 10:57:53 +00:00
gingerBill 5a23f52fb6 Merge branch 'master' of https://github.com/odin-lang/Odin 2025-10-27 18:51:57 +00:00
gingerBill a20c09158a Fix indentation 2025-10-27 18:51:51 +00:00
Laytan fca2232028 Merge pull request #5856 from A1029384756/master
[core:os/os2] zeroed `n` value on failed file operations
2025-10-27 18:05:38 +01:00
A1029384756 7afbe23a34 [core:os/os2] zeroed n value on failed file operations 2025-10-27 12:23:47 -04:00
Jeroen van Rijn 788ef8ee0a Merge branch 'master' of github.com:odin-lang/Odin 2025-10-27 16:24:04 +01:00
Jeroen van Rijn f726f7aff4 Make Karl Zylinski happy 2025-10-27 16:23:54 +01:00
gingerBill d9d7711ca4 Merge branch 'master' of https://github.com/odin-lang/Odin 2025-10-27 14:05:03 +00:00
gingerBill 78c3a3301c Change static_assert for OrderedInsertPtrMapEntry 2025-10-27 14:04:51 +00:00
gingerBill bccb2f1848 Merge pull request #5848 from Meliketoaste/egl_attrib_fix
Update GetPlatformDisplay and CreatePlatformWindowSurface to take in intptr_t/int instead of i32
2025-10-27 13:29:50 +00:00
Jeroen van Rijn eb0e99dac1 Fix #5852 2025-10-27 13:57:32 +01:00
gingerBill 8bdc322d6a Just use a method instead 2025-10-27 11:29:13 +00:00
gingerBill 288434ab30 One more time with a different cast? 2025-10-27 11:25:22 +00:00
gingerBill 62d231d685 Try C-cast with reintepret cast 2025-10-27 11:20:28 +00:00
gingerBill 6edb26dcf8 Use reinterpret_cast 2025-10-27 11:10:53 +00:00
gingerBill 13f2090608 Try to make PtrMap work for 32-bit compilers 2025-10-27 11:06:07 +00:00
gingerBill 43529dda38 Improve error message for missing & in some parapoly messages 2025-10-27 10:58:54 +00:00
Meliketoaste 562cf42348 Update GetPlatformDisplay and CreatePlatformWindowSurface to take in intptr_t/int inistead of i32 2025-10-25 15:42:04 +00:00
Jeroen van Rijn 81375e52ce Make time.components_to_time #optional_ok 2025-10-23 17:03:44 +02:00
Laytan 5511108e41 Merge pull request #5844 from cstrachan88/master
Fix #5843
2025-10-23 09:48:09 +02:00
Courtney Strachan e724b23aac Fix #5843 2025-10-23 03:18:03 -04:00
gingerBill 7c2101ea3d Merge pull request #5812 from Kelimion/data-alignment
Set minimum #load(file, type) alignment to 16 bytes
2025-10-22 11:27:18 +01:00
gingerBill 61424cfbf8 Merge pull request #5811 from wrathdoesthat/master
Fix orca linking path
2025-10-22 11:26:06 +01:00
gingerBill f5beb1aa9f Merge pull request #5813 from lmbarros/lmb/box2d-callbacks-signatures
Fix return types for vendor:box2d callbacks
2025-10-22 11:25:49 +01:00
gingerBill c332266e46 Merge pull request #5814 from laytan/wgpu-27.0.2.0
vendor/wgpu: update to 27.0.2.0
2025-10-22 09:47:23 +01:00
Jeroen van Rijn 0605c7b0e3 Add target triple and LLVM code mode debug prints (#5839) 2025-10-22 10:27:27 +02:00
gingerBill 55ab18f911 Fix #5831 2025-10-22 09:07:46 +01:00
Jeroen van Rijn 35df604d87 Merge pull request #5837 from chrishayen/epoll_packed_fix
Made packed conditional on EPoll_Event to match kernel
2025-10-21 20:25:54 +02:00
Jeroen van Rijn be81a2a36f Merge pull request #5835 from ekliot/vendor-box2d-bindings
`vendor:box2d` add `targetAngle` to `RevoluteJoint` struct/procs
2025-10-21 19:56:16 +02:00
Chris Hayen 492653e316 conditional packed for EPoll_Event to match kernel 2025-10-21 12:37:28 -04:00
Jeroen van Rijn fc5f121dae Merge pull request #5836 from Kelimion/ccitt_crc16
[core:hash] Add CCITT CRC-16
2025-10-21 16:40:41 +02:00
Jeroen van Rijn a1be1b63d5 [core:hash] Add CCITT CRC-16 2025-10-21 16:33:07 +02:00
ekliot 0e49ee8db7 vendor:box2d add targetAngle to RevoluteJoint struct/procs 2025-10-21 14:28:35 +01:00
Jeroen van Rijn 9df81bed9f Fix detached comment 2025-10-20 19:14:18 +02:00
Laytan 253a72ffe3 Merge pull request #5827 from jakubtomsu/5826-fix
[LLVM Backend] Prefer the type pointer over LLVMTypeRef when looking up struct_field_remapping (Fix 5826)
2025-10-18 17:46:58 +02:00
Jeroen van Rijn c51f4daa7d Let custom formatter example pass -vet-tabs if copied 2025-10-18 16:25:19 +02:00
jakubtomsu c21453acc5 comment 2025-10-18 16:18:58 +02:00
jakubtomsu 91750e2f1b prefer Type pointer over LLVMTypeRef when doing a struct_field_remapping lookup 2025-10-18 16:11:47 +02:00
Jeroen van Rijn 2339176083 Merge pull request #5825 from KamWithK/master
Linux executable path bug fix
2025-10-18 11:08:01 +02:00
Kamron Bhavnagri 2995536882 Fix Linux executable path
Fixes a bug caused by an executable named identically to the directory
it is in, where then the parent of that directory is both on the path
and marked as executable
Avoid this via stat, as we can check we are working with a file which is
executable
2025-10-18 14:33:35 +11:00
Jeroen van Rijn cf223e8307 Merge pull request #5824 from BradLewis/fix/parser-end-pos-multiline-string
Correct parser end_pos for multiline strings
2025-10-18 03:36:07 +02:00
Brad Lewis 44f823afce Correct parser end_pos for multiline strings 2025-10-17 21:25:17 -04:00
Jeroen van Rijn 2a8d9ee3f7 Merge pull request #5823 from Malmer/fix/box2d-math-functions
Fix source mismatches in vendor:box2d math functions
2025-10-18 02:25:02 +02:00
Fredrik Malmer 652eadf135 Fix IsNormalized to match the corresponding procedure in box2d 2025-10-18 01:18:50 +02:00
Fredrik Malmer 2550be59ef Change box2d epsilon to math C standard library 2025-10-18 01:18:05 +02:00
Laytan a7a0a9eaf6 vendor/wgpu: update to 27.0.2.0 2025-10-15 19:49:21 +02:00
Leandro Motta Barros bc1c856049 Fix return types for vendor:box2d callbacks 2025-10-15 13:51:26 -03:00
Jeroen van Rijn faa9222fef Set minimum #load(file, type) alignment to 16 bytes 2025-10-15 18:04:24 +02:00
wrathdoesthat 798f4b011c Merge branch 'odin-lang:master' into master 2025-10-15 10:09:47 -04:00
Wrath 6356cadfcc Fix orca linking path 2025-10-15 10:08:44 -04:00
Jeroen van Rijn 4b8751bebd Merge pull request #5810 from LeonardoTemperanza/master
Fix: #load(<string-path>, <type>) produces unaligned accesses
2025-10-15 16:04:02 +02:00
Username-Leon 4dd6bb2e87 Merge branch 'master' of https://github.com/LeonardoTemperanza/Odin 2025-10-15 15:30:32 +02:00
Username-Leon e10093bd99 Fix wrong alignment for typed load directive. 2025-10-15 15:30:06 +02:00
gingerBill 596066aa04 Merge pull request #5808 from laytan/llvm-21
llvm 21 support
2025-10-15 11:25:54 +01:00
Jeroen van Rijn 186589266b Merge pull request #5809 from Kelimion/bits
`core:math/bits` documentation and tests
2025-10-14 23:41:02 +02:00
Jeroen van Rijn ee93f48729 core:math/bits: Finish docs, add bitfield_extract + bitfield_insert test. 2025-10-14 23:30:38 +02:00
Jeroen van Rijn 347eae3a66 core:math/bits: Add docs + tests for rotate_left* and log2 2025-10-14 23:30:38 +02:00
Laytan e7ecb16a1e llvm 21 support 2025-10-14 19:55:00 +02:00
gingerBill 225edc552a Merge pull request #5801 from IllusionMan1212/egl-procs
vendor/egl: a few more procedures and constants
2025-10-14 17:52:57 +01:00
Jeroen van Rijn af5b73ecda Merge pull request #5807 from samwega/master
fix: typo
2025-10-14 18:21:03 +02:00
samwega 45f2822dd0 fix: typo 2025-10-14 19:11:49 +03:00
gingerBill 78e9a22ffa Fix track_graphemes 2025-10-13 15:47:35 +01:00
gingerBill 6a07d0e20a Merge pull request #5804 from odin-lang/bill/grapheme-iterator
Add `utf8.Grapheme_Iterator`
2025-10-13 15:41:03 +01:00
gingerBill 2bc7344f27 Add Grapheme_Iterator 2025-10-13 15:28:23 +01:00
Jeroen van Rijn 0d7efeab5f Merge pull request #5803 from Kelimion/fix-incidental-hang
Fix hang, courtesy of cloin.
2025-10-13 03:09:09 +02:00
Jeroen van Rijn 073e043b02 Fix hang, courtesy of cloin. 2025-10-13 02:59:57 +02:00
IllusionMan1212 36197a2de0 vendor/egl: a few more procedures and constants 2025-10-12 23:54:34 +02:00
gingerBill d267891ac9 Merge pull request #5797 from harold-b/hb.export-linked-libs
Add build flag to export the linked libraries
2025-10-12 10:52:50 +01:00
gingerBill 85005babc2 Merge pull request #5794 from alsakandari/improve-target-features
Improve target features flag by allowing the user to disable a target feature
2025-10-12 10:19:45 +01:00
gingerBill 9e836a2e49 Merge pull request #5783 from andzdroid/patch-1
Fix renamed function call in bit_not
2025-10-12 09:37:38 +01:00
Harold Brenes 612b219230 Fix -export-linked-libs-file system lib check 2025-10-12 02:00:18 -04:00
Harold Brenes 0de3de7257 Use exact value to determine system linked libs with -export-linked-libs-file 2025-10-12 01:57:29 -04:00
Harold Brenes 937161f68d Add -export-linked-libs-file build flag.
This build flag writes a list of the libraries that were linked during the build to the specified file.
2025-10-12 01:03:27 -04:00
ed 68c809c659 Merge remote-tracking branch 'offical/master' 2025-10-12 00:52:35 -04:00
ed a3533fe2da Prevent _alloc_command_line_arguments from crashing when defaulting to panic allocator. 2025-10-11 15:49:58 -04:00
Jeroen van Rijn de82f11710 Merge pull request #5795 from Kelimion/fix-5785
Fix #5785
2025-10-11 20:44:40 +02:00
Jeroen van Rijn e4db455458 Fix #5785 2025-10-11 20:32:09 +02:00
Jeroen van Rijn 5dbade87e9 Simple compare is also comparable 2025-10-11 15:43:30 +02:00
Jeroen van Rijn d1d8df3411 Merge pull request #5793 from Kelimion/checker-bugs
Checker bugs
2025-10-11 15:35:58 +02:00
Jeroen van Rijn e6754547ab Fix #5786 2025-10-11 15:17:23 +02:00
Jeroen van Rijn b3dfd34f2d #5788 2025-10-11 14:57:45 +02:00
Jeroen van Rijn 48a79a6f8c Fix #5789 2025-10-11 14:55:48 +02:00
Yhya Ibrahim c4a8af0f0d Check for + and - in the target features set 2025-10-11 15:48:12 +03:00
Yhya Ibrahim a672c68f03 Make -target-features flag support disabling of a feature 2025-10-11 15:26:01 +03:00
gingerBill 767098257e Merge pull request #5766 from rope-hmg/master
Added PointInRectFloat to SDL3
2025-10-11 11:03:38 +01:00
Jeroen van Rijn 227be05c0f Merge pull request #5773 from karl-zylinski/fontstash-ttc-fix
Fix fontstash crash with .TTC files
2025-10-11 01:10:54 +02:00
ed a5c73ad7b1 Merge tag 'dev-2025-10' 2025-10-10 18:47:30 -04:00
Karl Zylinski a4350b41ae Add fontIndex parameter to fontstash that controls which font in a TTC to load 2025-10-10 23:40:29 +02:00
andzdroid 77fa058d43 Fix renamed function call in bit_not
xor was renamed to bit_xor
2025-10-10 22:22:53 +01:00
Jeroen van Rijn 236111864e Link doc lines to source specifications. 2025-10-10 18:29:52 +02:00
Jeroen van Rijn 998fbdc5c0 Doc lines for vendor:* 2025-10-10 17:51:28 +02:00
Hector 65acbe1788 Changed indentation to tabs 2025-10-10 15:26:50 +01:00
gingerBill 7e7b6ac0de Add short-circuit for check_cast_internal 2025-10-10 14:37:18 +01:00
gingerBill 943105bc71 Merge branch 'master' of https://github.com/odin-lang/Odin 2025-10-10 14:31:48 +01:00
gingerBill 7e64dedb77 Fix #5778 2025-10-10 14:31:41 +01:00
Jeroen van Rijn a42f81edeb Start adding pkg lines for vendor. 2025-10-10 15:31:33 +02:00
Jeroen van Rijn e1d8ece408 core:sys/info: iterate over registry nodes to enumerate GPUs 2025-10-10 14:12:59 +02:00
gingerBill 0a3db1304d Merge pull request #5780 from odin-lang/bill/concatenate
`intrinsics.concatenate`
2025-10-10 12:52:48 +01:00
Jeroen van Rijn ad1cf25352 Increase timeout for posix.test_pthreads. 2025-10-10 13:35:32 +02:00
gingerBill 98dac324e9 Add to intrinsics.odin 2025-10-10 12:13:49 +01:00
gingerBill 26b3a4d182 Handle concatenation at the end 2025-10-10 12:09:41 +01:00
gingerBill 1387c3d311 Remove unneeded type expression 2025-10-10 12:04:22 +01:00
gingerBill 24bc044d78 Support fixed-length arrays for intrinsics.concatenate 2025-10-10 12:00:44 +01:00
gingerBill 5e12532eba Add basic type inference to the arguments 2025-10-10 11:50:02 +01:00
gingerBill 061b14e164 Allow intrinsics.concatenate to be variadic 2025-10-10 11:48:18 +01:00
gingerBill 1572ed57b6 Add intrinsics.concatenate 2025-10-10 11:40:36 +01:00
Jeroen van Rijn ece213afca Render examples. 2025-10-10 12:24:28 +02:00
gingerBill 4068eeb5fa Add Raw_String16/Raw_Cstring16 to core:mem 2025-10-10 09:57:53 +01:00
gingerBill 4723ec75ad Use sync.Mutex instead of a boolean-check for log.Log_Allocator 2025-10-10 09:47:31 +01:00
Jeroen van Rijn 7a9ea3ee6d Further overhaul of package line comments. 2025-10-09 23:05:29 +02:00
Jeroen van Rijn 2bc409eab5 More package lines. 2025-10-09 20:40:13 +02:00
Jeroen van Rijn 8a35acd506 More package lines. 2025-10-09 20:11:06 +02:00
Jeroen van Rijn c4c2431997 Package lines for core:math and more. 2025-10-09 19:56:21 +02:00
gingerBill b8fdd91c9f Merge pull request #5776 from connnnal/utf8-1-bounds
Disable bounds check for the first utf8 byte
2025-10-09 18:33:24 +01:00
gingerBill b04c3900ab Merge pull request #5774 from A1029384756/llvm-14-fixes
[llvm-14-fixes] fix `const_pad_to_size` for strings
2025-10-09 17:15:47 +01:00
A1029384756 be9384fc8d [llvm-14-fixes] use specific LLVMConst* codepaths for LLVM 14 2025-10-09 12:03:25 -04:00
Jeroen van Rijn 673358f8b9 Package lines for core:image. 2025-10-09 17:18:51 +02:00
Jeroen van Rijn 51cd08296f package lines for core:hash 2025-10-09 16:58:41 +02:00
Jeroen van Rijn 288b45f50c package lines for encoding 2025-10-09 16:34:18 +02:00
Jeroen van Rijn 248b0fe9e1 More package lines 2025-10-09 16:11:33 +02:00
gingerBill af189b45f3 Fix typo 2025-10-09 15:04:28 +01:00
gingerBill 0fc5efa50b Merge branch 'master' of https://github.com/odin-lang/Odin 2025-10-09 15:02:23 +01:00
gingerBill 025cb03242 Add all-bits to feature tag 2025-10-09 15:02:16 +01:00
gingerBill 940b0c54bc Add doc line to core:mem/virtual 2025-10-09 15:01:57 +01:00
Jeroen van Rijn d5a763e7d0 Merge branch 'master' of github.com:odin-lang/Odin 2025-10-09 15:28:00 +02:00
Jeroen van Rijn aec7d6480b Package lines for base32, move its tests to tests" 2025-10-09 15:27:53 +02:00
gingerBill c0fd19da18 Merge branch 'master' of https://github.com/odin-lang/Odin 2025-10-09 14:23:05 +01:00
gingerBill 8e410f8204 Add "possibly nil" comments to ast.odin 2025-10-09 14:22:56 +01:00
Jeroen van Rijn 153b0de420 Package lines for core:debug 2025-10-09 15:18:23 +02:00
Jeroen van Rijn 9c7fe1d8a7 Package lines for core:container. 2025-10-09 14:58:50 +02:00
Jeroen van Rijn 5a154a1775 Add more package lines for the docs 2025-10-09 14:41:22 +02:00
gingerBill c3d4b1f0b5 Add doc line to core:unicode/utf8/utf8string 2025-10-09 13:37:22 +01:00
gingerBill 857c78c22b Add doc lins to unicode packages 2025-10-09 12:37:18 +01:00
gingerBill 9ddb93bd01 Add doc line to core:thread 2025-10-09 12:29:18 +01:00
gingerBill 8019bd360a Add doc line to strconv 2025-10-09 12:28:16 +01:00
gingerBill 63ac9c7382 Add doc line to spall 2025-10-09 12:27:22 +01:00
gingerBill 3e8f4e080c Add more doc lines 2025-10-09 12:26:35 +01:00
gingerBill 87716da363 Add package line docs to c and libc 2025-10-09 12:23:59 +01:00
gingerBill c73bd6f51d Make Operation: comments unformatted 2025-10-09 11:42:09 +01:00
connnnal ee063e708a Disable bounds check for the first utf8 byte
Known safe from prior `n < 1` check
2025-10-09 11:38:22 +01:00
gingerBill a7b6ab92c1 Remove unused store 2025-10-09 11:32:25 +01:00
gingerBill adc44312bf const string -> constant string 2025-10-09 10:36:50 +01:00
gingerBill a60058259d Allow intrinsics.type_union_tag_offset with maybe-like unions 2025-10-09 10:25:48 +01:00
gingerBill 41c523faa5 Add intrinsics.type_is_raw_union 2025-10-09 10:10:49 +01:00
gingerBill 0b2c0f785c Add type_is_nearly_simple_compare to intrinsics.odin 2025-10-09 10:06:39 +01:00
gingerBill 7870e6d68b Update intrinsics.odin 2025-10-09 09:56:30 +01:00
gingerBill cadac43f14 Merge pull request #5765 from odin-lang/bill/new-slice-sort
New `slice.sort` implementation
2025-10-09 09:55:43 +01:00
gingerBill e001e402c2 Add intrinsics.type_is_cstring and intrinsics.type_is_cstring16 2025-10-09 09:55:14 +01:00
Karl Zylinski 79912b3a98 Fix for fontstash crash because it didn't fetch the offset of the first font correctly. The old setup didn't work with TTC files that contain multiple fonts. 2025-10-09 00:32:16 +02:00
Jeroen van Rijn 750c654536 Merge pull request #5772 from thetarnav/unicode-no-bounds-check
Add `#no_bounds_check` to procedures in `core:unicode`
2025-10-08 22:14:49 +02:00
thetarnav 3317a1f0e9 Add #no_bounds_check to procedures in core:unicode 2025-10-08 22:00:44 +02:00
Laytan f564f66c03 Merge pull request #5770 from harold-b/hb.fix-objc-superclass-check
Fix `@objc_superclass` attribute crashing when referenced type was invalid
2025-10-08 18:02:12 +02:00
Harold Brenes 9f5bde4a6f Perform type kind check before making use relevant fields in objc_superclass check 2025-10-08 11:38:20 -04:00
gingerBill 10259ee665 Minor rename of a procedure 2025-10-08 12:35:14 +01:00
gingerBill 7815d78f88 Merge branch 'master' into bill/new-slice-sort 2025-10-08 11:34:53 +01:00
gingerBill c1054d4d8e Merge pull request #5726 from LeonardoTemperanza/master
[vendor/vulkan] Fix bindings generator
2025-10-08 11:33:33 +01:00
gingerBill b427e025d7 Merge pull request #5629 from smercer10/fix-rbtree-find-or-insert
Fix rbtree.find_or_insert
2025-10-08 11:21:34 +01:00
gingerBill 39ace7f5c1 Merge pull request #5730 from 149-code/miniaudio_pcm_rb_commit
Removed unused pBufferOut parameters
2025-10-08 11:21:06 +01:00
gingerBill c7b38f855a Merge pull request #5768 from A1029384756/llvm-14-fixes
LLVM 14 Const Union Fixes
2025-10-08 11:18:35 +01:00
A1029384756 067fbfb48c Merge remote-tracking branch 'upstream/master' into llvm-14-fixes 2025-10-07 23:29:10 -04:00
A1029384756 cfe651e8d2 formatting 2025-10-07 23:26:29 -04:00
A1029384756 7179987ac9 casting 2025-10-07 23:15:12 -04:00
A1029384756 b55cf5f8f4 llvm 14 fixed 2025-10-07 22:58:50 -04:00
Jeroen van Rijn 5320feb673 Add reflect.as_string16 and fix typos 2025-10-07 22:54:35 +02:00
gingerBill 097a41a6cc Merge pull request #5739 from Creativty/master
Fix proc group named operands issue #4971
2025-10-07 15:34:33 +01:00
gingerBill 24253643d7 Merge pull request #5757 from Creativty/fix_out_of_place_default_params_exclusion
Fix #5734, Default params exclusion counting in proc groups issue
2025-10-07 15:34:02 +01:00
gingerBill d17ee79470 Fix #5764 2025-10-07 14:30:13 +01:00
gingerBill 20e67f2ad9 Add some more docs 2025-10-07 14:27:19 +01:00
gingerBill 13b8607cc3 Add _internal_sort_from_indices_permuation 2025-10-07 14:15:40 +01:00
gingerBill af8c698b97 use ctx 2025-10-07 13:24:13 +01:00
gingerBill 9e068c254b Fix typos 2025-10-07 13:22:15 +01:00
gingerBill 85e37f2f7e Add missing nil 2025-10-07 13:18:30 +01:00
Hector 1aa3283d1b Added PointInRectFloat to SDL3 2025-10-07 12:58:08 +01:00
gingerBill b90c806386 Remove context._internal usage 2025-10-07 12:42:50 +01:00
gingerBill f40fc2792f Replace normal sort procedure with a simpler unified type-erased one 2025-10-07 12:38:01 +01:00
gingerBill 1400952530 Merge examples 2025-10-07 12:07:40 +01:00
gingerBill d14576e843 Space to tabs 2025-10-07 12:00:59 +01:00
gingerBill 56f275bc71 Fix typo 2025-10-07 11:52:49 +01:00
gingerBill 1a90b06fac Improve documentation for core:reflect 2025-10-07 11:49:56 +01:00
gingerBill a4a74442ce Add some basic docs to Default_Temp_Allocator 2025-10-07 10:41:52 +01:00
gingerBill 47cfee1f62 Add docs to nil_allocator and panic_allocator 2025-10-07 10:38:50 +01:00
gingerBill d343afbad5 Improve core_builtin.odin docs 2025-10-07 10:34:48 +01:00
gingerBill 66401b2e73 Minor formatting changes 2025-10-07 10:16:13 +01:00
gingerBill 787c3a7298 Remove @(require_results) on find_aux 2025-10-07 09:50:05 +01:00
gingerBill fb93713f24 Add @(rodata) and @(require_results) to core:text/match 2025-10-07 09:45:54 +01:00
gingerBill 5a12ccef44 Add unicode.simple_fold; Finish (strings|bytes).equal_fold 2025-10-07 09:40:54 +01:00
gingerBill 1708cb556a Improve docs for core:bufio; Rename scanner_scan -> scan (keep alias of old name) 2025-10-07 09:10:55 +01:00
gingerBill 185e7cd538 Merge pull request #5760 from harold-b/hb.fix-objc-block-name-collision
Fix Objective-C block symbols naming conflict across modules
2025-10-06 13:27:47 +01:00
gingerBill bc9e6f852e Merge pull request #5762 from A1029384756/llvm-14-entry-fix
[llvm-14-entry-fix] bitcast context pointer to match types for llvm 14
2025-10-06 13:26:52 +01:00
gingerBill 408f318541 Merge pull request #5744 from FrancisTheCat/master
Fix srgb <-> linear rgb conversion functions in `core:math/linalg`
2025-10-06 13:26:39 +01:00
Jeroen van Rijn 9a0b0bc3ff Merge pull request #4896 from cstrachan88/master
Fixed json null value parsing
2025-10-06 13:00:28 +02:00
A1029384756 866486fa1c [llvm-14-entry-fix] bitcast context pointer to match types for llvm 14 2025-10-06 00:12:31 -04:00
Courtney Strachan 69ad94d8a8 Followup fix to #4895 2025-10-05 19:22:04 -07:00
Courtney Strachan 6de2d6e8ca Merge branch 'odin-lang:master' into master 2025-10-06 02:41:44 +01:00
Harold Brenes e79e53dbbd Use module-prefixed naming scheme for tracking
objc block instead of shared id counter.
2025-10-05 16:14:32 -04:00
Harold Brenes 86f9c920da Fix Objective-C block symbols naming conflict across modules.
Fix assert triggered when there's checker errors and
 Objective-C method implementations.
2025-10-05 15:53:42 -04:00
gingerBill 0f97382fa3 Merge pull request #5759 from Creativty/fix_wasm_undefined_this_mem
Fix #5225 wasm odin.js undefined this.mem
2025-10-05 20:33:36 +01:00
gingerBill 3f7fc1e9bf Merge pull request #5738 from jakubtomsu/fix-simd-ptr-transmute
[LLVM backend] SIMD vector transmute only uses bitcast when the elements aren't pointers
2025-10-05 20:27:23 +01:00
gingerBill 810ca89253 Merge pull request #5727 from harold-b/hb.intrinsics.objc_super
Add intrinsics.objc_super and Automatically emit objc_msgSend calls
2025-10-05 20:27:01 +01:00
xenobas 3edf964b55 Fix #5225 wasm odin.js undefined this.mem 2025-10-05 20:18:41 +01:00
xenobas 61db9c71f6 Fix non infix params with default value exclusion counting 2025-10-05 15:46:02 +01:00
Jeroen van Rijn 7237747ee7 Try fix macOS Intel nightlies. 2025-10-05 15:19:58 +02:00
Jeroen van Rijn 138cc7da1f Merge pull request #5749 from samwega/deprecate_c_procs
Deprecate c procs
2025-10-05 13:32:04 +02:00
Jeroen van Rijn 3ad7240d3d Merge pull request #5755 from alsakandari/fix-regression
Remove a debug printf that caused regression
2025-10-05 11:38:18 +02:00
Yhya Ibrahim 89a5e93818 Remove a debug printf that caused regression 2025-10-05 09:56:03 +03:00
Jeroen van Rijn 9ed125bcf6 Merge pull request #5752 from connnnal/tprint-comment
Remove inaccurate tprint concern
2025-10-04 16:50:13 +02:00
ed 44063a62fa Update c++ codegen 2025-10-04 10:15:17 -04:00
ed 0a820a9f71 Merge remote-tracking branch 'offical/master' 2025-10-04 10:05:37 -04:00
connnnal c6300de0d1 Remove inaccurate tprint concern 2025-10-04 14:58:28 +01:00
samwega 9da10dece2 fix: another itoa() used in path_linux.odin had to be replaced with write_int() 2025-10-03 22:26:24 +03:00
samwega 9e9d41ddfd fix: cars i64 instead of int 2025-10-03 22:17:25 +03:00
samwega 83d36451a3 os_linux.odin was using itoa, changed to use write_int() 2025-10-03 22:13:03 +03:00
samwega bbf297f265 fix: copy/paste error 2025-10-03 21:18:38 +03:00
samwega 2af3f280bf Tetralux asked for int_tostring() to also be deprecated, use write_int() instead. 2025-10-03 21:14:54 +03:00
samwega 01bbd981ad short C names deprecated (itoa, ftoa), C reimplementations of atoi and atof deprecated as parse_int() and parse_f64() are preferable 2025-10-03 20:54:18 +03:00
Jeroen van Rijn 6d8f4b85a8 Merge pull request #5745 from samwega/master
digit_to_int in strconv.odin
2025-10-02 20:11:57 +02:00
samwega 54805c600e After discord debate: replaced rtoi and utoi with just digit_to_int and simple comment 2025-10-02 20:45:00 +03:00
Franz Hoeltermann a39697d84c Fix srgb <-> linear rgb conversion functions in core:math/linalg and add implementations for vector3 2025-10-02 17:31:59 +02:00
Jeroen van Rijn b2e695e634 Merge pull request #5742 from samwega/utoi_and_rtoi_strconv
feat: added rtoi & utoi to core/strconv/strconv.odin
2025-10-02 14:53:58 +02:00
samwega 84e8b8d1ad fix: copy/paste replaced tabs with spaces 2025-10-02 15:45:21 +03:00
samwega 7eb26d8eac feat: added rtoi & utoi procs for converting a rune and a u8 character respectively to int 2025-10-02 15:21:44 +03:00
xenobas 0158e4009b Fix proc group named operands issue #4971 2025-10-01 18:01:10 +01:00
Jakub Tomsu 588513a510 bitcast only non-pointer-like-element simd vectors, handle others like other aggregate types 2025-10-01 15:54:32 +02:00
Harold Brenes 2daaf57ad1 Correct signature (missing return value) for objc_msgSendSuper2 2025-09-30 14:16:43 -04:00
gingerBill ea7e9bc11c Merge pull request #5732 from harold-b/hb.preempt-field-check-sig-similar-enough
Preempt field checking on `signature_parameter_similar_enough` with a type ptr equality check
2025-09-30 17:51:23 +01:00
Harold Brenes a769e341cb Preempt field checking on signature_parameter_similar_enough with a type ptr equality check 2025-09-30 11:50:30 -04:00
gingerBill 4945168e6d Short circuit for #raw_union in signature_parameter_similar_enough 2025-09-30 10:48:05 +01:00
gingerBill 668df4a571 Improve signature_parameter_similar_enough for structs 2025-09-30 10:47:31 +01:00
gingerBill 748b4cdc6b Merge pull request #5729 from harold-b/hb.fix-foreign-signatures
Relax `signature_parameter_similar_enough` on struct params and fix various foreign signatures
2025-09-30 10:41:51 +01:00
gingerBill 51a8660d52 Disallow dynamic-literals withint procedure scopes where context is not defined 2025-09-30 10:24:20 +01:00
149-code 8908e82258 Removed unused pBufferOut parameters 2025-09-29 23:36:14 -05:00
Harold Brenes fc44b10431 Include objc runtime type dependencies only on darwin 2025-09-29 20:38:16 -04:00
Harold Brenes 481deee4ae Fix entity nullptr check 2025-09-29 20:38:16 -04:00
Harold Brenes 9425954861 Ignore patterns for local development in CMake 2025-09-29 20:38:16 -04:00
Harold Brenes 6d9ace4a2c Remove outdated todo 2025-09-29 20:38:16 -04:00
Harold Brenes 5af13f5d53 Automatically emit objc_msgSend calls when calling imported or implemented Objective-C methods
- Add intrinsics.objc_super()

- Emit objc_msgSendSuper2 calls when an objc method call is combined with objc_super(self)

- Fix objc_block return value ABI for large struct returns

- Fix objc_implement method wrappers bad ABI for large struct returns and indirect args

- Simplify parameter forwarding for objc_imlpement methods

- Add intrinsics.objc_instancetype to mimi Objective-C instancetype* returns
  This facilitates returning the correct type on subclasses when calling mehtods
  such as `alloc`, `init`, `retain`, etc.

- Refactor Objective-C class implementations generation so that hierarchies are properly initialized

- Better codegen for context passing with ivar-based autocontext

- Allow @superclass on imported objc-c objects

- Better codegen for block forwarding invoker, arguments are forwarded directly
2025-09-29 20:37:48 -04:00
Harold Brenes 0fdac0bd8c Fix test inet_pton call in test_arpa_inet 2025-09-29 20:29:34 -04:00
Harold Brenes c23d30f050 Fix printf format 2025-09-29 19:58:28 -04:00
Harold Brenes 24daa4427c Fix various foreign signatures 2025-09-29 19:58:14 -04:00
Username-Leon d203dff09f Removed 0UL check.
Thought unsigned long was consistent across platforms
2025-09-29 19:09:11 +02:00
Username-Leon cef381261a Fixed vulkan bindings.
In vendor/vulkan, vendor constants ending with EXT/AMD/NV/NVX/GOOGLE/KHX (all except KHR) are now present. VK_SHADER_UNUSED_KHR (as well as others previously absent) was improperly translated from (~0U) to 0. Explicit checks for "(~0U)", "(~0UL)" and "(~0ULL)" have been added to produce ~u32(0) and ~u64(0). Hardcoded constants in the bindings generator ending with EXT have been removed as they are now properly caught by the regex.
2025-09-29 18:44:07 +02:00
gingerBill 34d040cef1 Correct format strings 2025-09-29 16:51:38 +01:00
gingerBill 9e8be055c1 Rename to -build-diagnostics 2025-09-29 16:16:19 +01:00
gingerBill 11712627cb Add module stuff to -para-poly-diagnostics 2025-09-29 16:14:55 +01:00
gingerBill 9b4c0ea492 Type erase the internals of runtime.copy_* 2025-09-29 15:12:55 +01:00
gingerBill 17394d8b14 Merge pull request #5725 from odin-lang/bill/parapoly-diagnostics
`-para-poly-diagnostics`
2025-09-29 15:10:57 +01:00
gingerBill 1fc1d8e451 Change sort for single instanced procedures 2025-09-29 14:32:21 +01:00
gingerBill 53f4fc1cbb Add -para-poly-diagnostics 2025-09-29 14:03:32 +01:00
gingerBill 11dc6680d2 Merge pull request #5723 from odin-lang/bill/const-union
Basic support for constant union literals
2025-09-29 13:12:07 +01:00
gingerBill 240b2f1819 Disable #raw_union constants for the time being 2025-09-29 12:54:52 +01:00
gingerBill b711e92968 Add bit cast 2025-09-29 12:27:28 +01:00
gingerBill 89645921e2 Only add packing if the padding is non-zero for a #raw_union constant 2025-09-29 11:00:08 +01:00
gingerBill e511f07d76 Short circuit for Union{} 2025-09-29 10:45:24 +01:00
gingerBill 0d946268ee Disallow constant access x.y on struct #raw_union 2025-09-29 10:41:35 +01:00
gingerBill 10ba956d6a Rudimentary support for some constant struct #raw_union 2025-09-29 10:28:16 +01:00
gingerBill 1f2cedcf78 Remove debug code 2025-09-29 09:53:04 +01:00
gingerBill 4f442c6045 Rearrange const union initialization so that it is priority 2025-09-29 09:51:23 +01:00
gingerBill 4877214f34 Add more check_is_operand_compound_lit_constant uses 2025-09-28 23:53:07 +01:00
gingerBill dd15a5bc8e Do not need an extra local copy for the slices 2025-09-28 23:32:37 +01:00
gingerBill 6db8943efa Check for empty compound literal early for constants 2025-09-28 23:25:27 +01:00
gingerBill 5b88d2363d Correct failure check for const cast 2025-09-28 23:19:43 +01:00
gingerBill cbab97fbd7 Use memcpy for local constant slice arrays from a global constant 2025-09-28 22:50:36 +01:00
gingerBill 17c9e1d76b Fix global initialization when non was set 2025-09-28 22:11:46 +01:00
gingerBill 1df9f1d01d Fix constant union{proc()} 2025-09-28 22:02:25 +01:00
gingerBill 8be18d9a40 Allow for constant []typeid 2025-09-28 21:47:56 +01:00
gingerBill 35a32d41e0 Fix Union{} 2025-09-28 21:08:47 +01:00
gingerBill f743110f63 Correct union type checking for constants 2025-09-28 21:00:36 +01:00
gingerBill 421bec2d17 Merge branch 'master' into bill/const-union 2025-09-28 20:48:23 +01:00
gingerBill d3b8770318 Add #+test to base32_test.odin 2025-09-28 20:48:13 +01:00
gingerBill 547477abf6 Add #+test to replace _test.odin 2025-09-28 20:47:32 +01:00
gingerBill 17204bd1c2 Global const unions with @(rodata) 2025-09-28 20:40:26 +01:00
gingerBill ffdfbfe2c2 Begin to support constant array of unions 2025-09-28 20:20:26 +01:00
gingerBill a974c51d57 First step towards constant unions 2025-09-28 19:52:52 +01:00
gingerBill 0233dc5d31 Remove stray 0 2025-09-27 14:15:51 +01:00
gingerBill e9f6456b52 Remove _test.odin filter 2025-09-27 14:13:28 +01:00
gingerBill af83c30b6f And extra safety checks 2025-09-27 14:13:16 +01:00
gingerBill 27d9ab5dd8 Merge pull request #5719 from jwaxy/patch-1
Prevent returning a struct containing compound literal slice
2025-09-27 14:11:57 +01:00
Jwaxy 15fe0bfe59 Make return struct with slice check recursive 2025-09-27 14:45:46 +03:00
Jwaxy 4165e8e888 Prevent returning struct containing compound literal slice 2025-09-27 13:53:04 +03:00
gingerBill a7af6055b0 Move memory mutex guard around for resize in virtual.Arena allocator 2025-09-27 10:27:08 +01:00
gingerBill 2c97b4ee4d Merge pull request #5718 from odin-lang/bill/conditional-zero
Add `runtime.conditional_mem_zero` to improve `heap_allocator` performance on non-Windows systems
2025-09-27 10:17:23 +01:00
gingerBill 2baa19f73c Remove unused variable 2025-09-27 10:10:25 +01:00
gingerBill ac01d1b5bf Add runtime.conditional_mem_zero to improve heap_allocator performance on non-Windows systems 2025-09-27 09:58:28 +01:00
gingerBill 0eaf3ee7cd Merge pull request #5678 from alexriedl/wrong-allocator-guard
fix for temp_file name prefix being deallocated before being used
2025-09-26 15:24:11 +01:00
gingerBill 1222d40d39 Merge pull request #5691 from rationalcoder/master
Fix out-of-band allocations in dynamic arenas
2025-09-26 14:21:52 +01:00
gingerBill 51f79724ed Merge pull request #5686 from thetarnav/zero-small-array-resize
Zero small array resize
2025-09-26 14:16:54 +01:00
gingerBill 62a03f118e Merge pull request #5689 from slowhei/master
Improve type inferencing of literals when calling proc groups
2025-09-26 14:13:05 +01:00
Jeroen van Rijn af097f6ea1 Make CodeCov less touchy. 2025-09-26 12:05:16 +02:00
gingerBill 23778cd643 Merge pull request #5716 from samwega/master
-fix: typo
2025-09-26 11:00:36 +01:00
gingerBill dfb86db159 Fix absolutely random change between , and newline 2025-09-26 10:50:16 +01:00
gingerBill 01c10f3f5e Use RecursiveMutex to fix a race condition with parapoly records 2025-09-26 10:18:46 +01:00
samwega ade4eafcad -fix: typo 2025-09-26 11:53:53 +03:00
gingerBill 42b9039a1f Check for nullptr 2025-09-26 09:41:08 +01:00
gingerBill b1d63f103e Merge branch 'master' of https://github.com/odin-lang/Odin 2025-09-26 09:35:58 +01:00
gingerBill ed2b79a63e Completely comment out lb_construct_const_union 2025-09-26 09:35:51 +01:00
gingerBill db74ce7cbf Merge pull request #5712 from greenya/master
[core:sys/info] doc: Remove duplicated line
2025-09-26 09:34:25 +01:00
gingerBill a6d5ec2de8 Early short circuit lb_construct_const_union 2025-09-26 09:31:10 +01:00
Yuriy Grynevych 36098cec0f [core:sys/info] doc: Remove duplicated line 2025-09-25 15:14:42 +03:00
gingerBill 0ae86dbe87 Ignore further 2025-09-25 12:10:18 +01:00
gingerBill 8b7a35fae2 MAKE_VERSION be "contextless" 2025-09-25 12:07:08 +01:00
gingerBill 1a191b99ac Disable some of lb_construct_const_union for the time being. 2025-09-25 12:05:27 +01:00
gingerBill a3689f89c2 Merge pull request #5706 from wrathdoesthat/master
Unify filepath.join return between unix/windows
2025-09-25 09:29:38 +01:00
gingerBill 286e3eafe6 Change inlining semantics for some builtin calls 2025-09-25 08:55:03 +01:00
Tohei Ichikawa 654c5b2c06 Fix memory leaks in type inference test 2025-09-24 21:25:25 -04:00
Tohei Ichikawa 6ed9351955 Merge remote-tracking branch 'upstream/master' 2025-09-24 21:09:31 -04:00
Tohei Ichikawa 3c1238991b Fix test_proc_group_type_inference.odin 2025-09-24 18:52:48 -04:00
gingerBill 5d3092bf2d Again, better const union stuff 2025-09-24 14:27:44 +01:00
gingerBill 43e0d6966e More improves for const union stuff! 2025-09-24 14:07:09 +01:00
gingerBill ad85ec765b More const union improvements 2025-09-24 10:29:32 +01:00
gingerBill bad495519b Improve const union attemps 2025-09-24 10:08:25 +01:00
gingerBill 31f0aaa62f Try to improve const union LLVM construction 2025-09-24 09:55:22 +01:00
gingerBill 90d1229ead Make LLVM_WEAK_MONOMORPHIZATION opt-in again 2025-09-24 09:13:48 +01:00
gingerBill b9e90194d8 Merge pull request #5707 from janga-perlind/lucas/timing-stuff
Improve OSX threading performance
2025-09-24 08:20:26 +01:00
Lucas Perlind 15b4b9277a spin in recursive mutex lock; use compare exchange for broadcast 2025-09-24 15:54:58 +10:00
Wrath 443b6e1641 Unify filepath.join behavior on between unix/windows 2025-09-23 23:03:20 -04:00
Lucas Perlind eca2758d8b Revert "Reimplement RwMutex on non-windows systems"
This reverts commit e9d20a9b4a.
2025-09-24 12:40:01 +10:00
gingerBill e9d20a9b4a Reimplement RwMutex on non-windows systems 2025-09-23 11:38:32 +01:00
gingerBill 2f132b51ce Add missing gen 2025-09-23 01:23:01 +01:00
gingerBill c9eef7c835 Single thread lb_create_startup_runtime_generate_body 2025-09-22 21:10:01 +01:00
gingerBill f36ade8c64 Remove extra checks 2025-09-19 16:44:57 +01:00
gingerBill 9b8771b475 Handle missing procedures better 2025-09-19 16:15:04 +01:00
gingerBill 655176e5e7 Remove comments of dead code 2025-09-19 15:17:38 +01:00
gingerBill 76705c6800 Convert missing_procedures_to_check to a queue 2025-09-19 14:18:09 +01:00
gingerBill 6bca1475ed Convert procedures_to_generate to a queue 2025-09-19 14:15:25 +01:00
gingerBill ee3b10335b Split further 2025-09-19 13:59:58 +01:00
gingerBill f1e3977cf9 Split up startup call into separate calls 2025-09-19 13:57:52 +01:00
gingerBill ec91e2c15b Separate ini global var stuff 2025-09-19 13:52:25 +01:00
gingerBill a8b2b1a23b Temporarily revert anonymous procedure load balancing 2025-09-19 13:49:09 +01:00
gingerBill 31cafda30d Remove unused variable 2025-09-19 12:31:06 +01:00
gingerBill be1e889abb Remove debug message 2025-09-19 12:29:26 +01:00
gingerBill 6338e0a8a3 Allow unions with one variant to be constant 2025-09-19 11:56:44 +01:00
gingerBill 1a4da5cb0f Distribute anonymous procedure literals correctly across LLVM modules 2025-09-19 11:13:18 +01:00
gingerBill 6ce889f4eb Entity * to std::atomic<Entity *> to remove the need for a PtrMap+Mutex 2025-09-19 11:01:41 +01:00
gingerBill 5f76d6ce15 Support -linker:mold 2025-09-19 10:25:11 +01:00
gingerBill 1507cc01a5 Merge branch 'master' of https://github.com/odin-lang/Odin 2025-09-18 23:26:23 +01:00
gingerBill 5d14df4112 Multithread lb_module_init 2025-09-18 23:26:11 +01:00
gingerBill 4d2854f561 Merge pull request #5632 from kalsprite/x386
windows i386 support
2025-09-18 22:01:14 +01:00
gingerBill 9cf69576ab More improvements to minimize code gen size 2025-09-18 20:58:24 +01:00
gingerBill 4b0a07ba27 Minor rearrangement 2025-09-18 17:06:09 +01:00
gingerBill 37e1e00623 Revert global procedure threading 2025-09-18 16:57:21 +01:00
gingerBill 5bc9d79f77 Change mutex usage for missing procedures 2025-09-18 16:56:19 +01:00
gingerBill 111e2f0c1b After global procedures and types are generated, then queue the generation of the procedures for each module 2025-09-18 16:53:00 +01:00
gingerBill 5559916d5c Mulithread startup procedure body generation 2025-09-18 16:35:04 +01:00
gingerBill 3954491393 Type erasure to minimize code generation size 2025-09-18 15:54:05 +01:00
gingerBill 0f307fbc5d Use multiple modules per file in package runtime 2025-09-18 15:34:19 +01:00
gingerBill 738a72943b Try moving parapoly procs into a separate module when doing weak monomorphization 2025-09-18 15:04:16 +01:00
gingerBill 5b0510a6bd Merge pull request #5690 from Creativty/master
Fix #5682 segfault involving string_to_string16 on linux
2025-09-17 17:28:24 +01:00
rationalcoder 710533975e Fix out-of-band allocations in dynamic arenas 2025-09-16 16:31:10 -05:00
xenobas 3e7395eba6 fix: fix segfault on string_to_string16 2025-09-16 21:40:57 +01:00
Tohei Ichikawa 5e71ba4456 Remove an outdated TODO 2025-09-16 10:57:54 -04:00
Tohei Ichikawa 403ca2fb2e Improve type inferencing of literals when calling proc groups 2025-09-15 20:40:20 -04:00
Damian Tarnawski e163c20a02 Correct set_example in small_array 2025-09-15 15:29:17 +02:00
Damian Tarnawski 40c8f45a81 Correct small_array resize examples 2025-09-15 15:15:44 +02:00
Damian Tarnawski b986c534a3 Replace mem.zero_slice with intrinsics.mem_zero in small_array.resize 2025-09-15 15:01:20 +02:00
Damian Tarnawski 7adc33d5a4 Add @require to core:mem import in small_array 2025-09-15 14:56:46 +02:00
Damian Tarnawski 2c3d5fe456 Add small array resize tests 2025-09-15 14:50:33 +02:00
Damian Tarnawski 3d66625de0 Zero memory in small_array.resize and add non_zero_resize 2025-09-15 14:40:58 +02:00
gingerBill 11be0cb4ab Use permanent_allocator() instead of temporary_allocator() temporarily to fix a bug 2025-09-14 17:37:17 +01:00
gingerBill 7db57e2d9c Temporarily disable TEMPORARY_ALLOCATOR_GUARD 2025-09-14 17:24:22 +01:00
gingerBill 22261f9e71 Fix temporary_allocator 2025-09-14 17:21:33 +01:00
ed 00bc86993c Merge tag 'dev-2025-09' 2025-09-14 10:09:53 -04:00
Jeroen van Rijn e0a97a628d Merge pull request #5683 from thetarnav/soa-get-safe-contextless
Add "contextless" to small_array get_safe and get_ptr_safe
2025-09-14 13:01:52 +02:00
Damian Tarnawski 3e62c2c79a Add "contextless" to small_array get_safe and get_ptr_safe 2025-09-14 10:39:33 +02:00
gingerBill 935d9657a3 Merge pull request #5677 from slowhei/master
Fix Drawin addObserver methods and add support for new Objc_Block
2025-09-12 08:44:45 +01:00
Alex Riedl b9a09cebee fix for temp_file name prefix being deallocated before being used 2025-09-11 10:55:29 -05:00
Tohei Ichikawa a454633774 Fix addObserver methods and add support for new Objc_Block 2025-09-11 09:50:31 -04:00
gingerBill 72f8bafe6c Merge pull request #5672 from thetarnav/strings-builder-caller-location
Add missing caller location param to append in strings builder
2025-09-11 11:02:35 +01:00
gingerBill cf4262d22c Merge branch 'master' of https://github.com/odin-lang/Odin 2025-09-10 21:41:58 +01:00
gingerBill 5ea2e1fe60 Minimize mutex usage when in single threaded mode. 2025-09-10 21:41:52 +01:00
gingerBill 8175c3eaa1 Merge pull request #5651 from FourteenBrush/patch-2
Win32: add `CancelIoEx` to kernel32.odin, among other overlapped IO functions.
2025-09-10 21:36:37 +01:00
gingerBill 992cad101c Minor mutex rearrangement 2025-09-10 21:16:56 +01:00
gingerBill 549edcc0f9 Use a RwMutex instead of BlockingMutex 2025-09-10 21:00:43 +01:00
gingerBill 34e3d30780 More thread contention removal 2025-09-10 20:51:52 +01:00
gingerBill 0476d33a6c Remove global PtrMap<Type *, GenTypesData *> and store on the TypeNamed directly 2025-09-10 20:45:26 +01:00
gingerBill d3602ca634 Removal of some old checks 2025-09-10 20:37:39 +01:00
gingerBill 76c0f89535 Merge branch 'master' of https://github.com/odin-lang/Odin 2025-09-10 20:11:42 +01:00
gingerBill bc36ea4170 Use macro instead of a C++ iterator - for speed
C++ iterators are bad.
2025-09-10 20:11:36 +01:00
Jeroen van Rijn 641ccf89a2 Merge pull request #5676 from Kelimion/big-asan
Change the way math/big constants are initialized
2025-09-10 21:09:16 +02:00
gingerBill 228ddd6903 Inline some ptr set iterators 2025-09-10 20:02:39 +01:00
Jeroen van Rijn 3c9538c708 Change the way math/big constants are initialized 2025-09-10 21:02:24 +02:00
gingerBill 1c648126c7 Move more from heap_allocator() to temporary_allocator() 2025-09-10 19:47:29 +01:00
gingerBill 01258d4817 Multithread "check all scope usages" 2025-09-10 19:38:30 +01:00
gingerBill a36a8722dc Minimize more thread contention 2025-09-10 19:30:32 +01:00
gingerBill 21b1173076 Minor clean up of permanent/temporary arena usage 2025-09-10 18:20:20 +01:00
gingerBill af37ba76c1 Use arena in calculate_global_init_order 2025-09-10 18:02:02 +01:00
gingerBill 54df0e1a41 Merge branch 'master' of https://github.com/odin-lang/Odin 2025-09-10 17:29:17 +01:00
gingerBill 1e0902677f Multithread min dep set by removing the set itself 2025-09-10 17:29:11 +01:00
gingerBill fef00dda24 Merge pull request #5675 from jfcode4/master
Fix incorrect json encoding for control characters < 32
2025-09-10 16:09:52 +01:00
Jacob Friedman 9492dccb4a Fix incorrect json encoding for control characters < 32 2025-09-10 16:50:12 +02:00
gingerBill 475791476b Merge pull request #5673 from BradLewis/fix/parser-proc-group-trailing-comma
Allow missing trailing comma with proc groups with odin parser
2025-09-10 13:48:13 +01:00
Brad Lewis 75449283c2 Allow missing trailing comma with proc groups with odin parser 2025-09-10 08:44:06 -04:00
gingerBill 60684ff028 Multithread some of the min dep system 2025-09-10 13:39:06 +01:00
gingerBill 70d396c8ad Split type and inline cycles into separate loops 2025-09-10 13:26:07 +01:00
gingerBill 629777b988 Multithread check_update_dependency_tree_for_procedures 2025-09-10 12:42:36 +01:00
Damian Tarnawski 413b44d05c Add missing caller location param to append in strings builder 2025-09-10 13:23:56 +02:00
Jeroen van Rijn 1d561247f5 Add nullptr checks to more type helpers. 2025-09-09 20:45:32 +02:00
Jeroen van Rijn edc58c020c Merge pull request #5670 from Kelimion/jpeg-updates
Small updates to JPEG loader
2025-09-09 18:52:30 +02:00
Jeroen van Rijn cd3069b16b Small updates to JPEG loader
- Remove some unnecessary nesting
- Add frame type (SOF0, et al) to metadata if `.return_metadata` is used
2025-09-09 18:34:19 +02:00
Jeroen van Rijn 6b18f8df63 Merge pull request #5668 from Kelimion/jpeg-updates
`core:image/jpeg` updates
2025-09-09 17:20:53 +02:00
Jeroen van Rijn 572b26a846 Expand grayscale JPEGs to RGB(A)
And handle grayscale jpeg example file in test suite.
2025-09-09 17:13:21 +02:00
Jeroen van Rijn 7b3ca701e0 Implement .alpha_add_if_missing for JPEG 2025-09-09 14:51:16 +02:00
FourteenBrush eb7218eff0 Merge branch 'odin-lang:master' into patch-2 2025-09-09 14:41:28 +02:00
Jeroen van Rijn 737c87a726 Optionally save BMP 2025-09-09 14:12:48 +02:00
FourteenBrush fb1dd3052d Add RtlNtStatusToDosError ERROR_MR_MID_NOT_FOUND error 2025-09-09 14:11:38 +02:00
FourteenBrush 64e9652776 Add RtlNtStatusToDosError
Maps kernel NTSTATUS to win32 system error
2025-09-09 14:04:36 +02:00
Jeroen van Rijn dd9fceaae1 Make progressive JPEGs return a proper error
Add progressive JPEG file to test suite and test that loading it returns the expected `Unsupported_Frame_Type` error.

This JPEG variant will hopefully be supported in the future, but we should at least return an error rather than use `unsupported()`.
2025-09-09 13:53:43 +02:00
gingerBill 9abc3f67b5 Fix constant procedure parameters when passing literals 2025-09-09 10:36:22 +01:00
gingerBill e2c1f86946 Merge pull request #5663 from greenya/master
[core:time] time_js: tick_now(): Use f64 (was f32) as a return type of odin_env.tick_now()
2025-09-08 18:25:08 +01:00
Jeroen van Rijn 690291d4cd Merge pull request #4695 from IllusionMan1212/jpeg
core/image: Add jpeg support
2025-09-08 18:42:48 +02:00
Jeroen van Rijn fa36c6a5f5 Add JPG test assets to .gitignore 2025-09-08 18:19:21 +02:00
Jeroen van Rijn 2de4918fb3 Add basic test for JPG using Odin emblem 2025-09-08 18:18:08 +02:00
Jeroen van Rijn 2f59e0175e Address some naming issues 2025-09-08 17:44:58 +02:00
Jeroen van Rijn 5b60067131 Fix examples/all 2025-09-08 17:25:55 +02:00
Jeroen van Rijn 14bf730a2c Make _register contextless 2025-09-08 17:17:14 +02:00
IllusionMan1212 cb820eea4d jpeg: extract Exif data 2025-09-08 17:13:03 +02:00
IllusionMan1212 57a92b14cc jpeg: support images that encode zero-based component ids 2025-09-08 17:13:03 +02:00
Hisham Aburaqibah 694593c5f2 image/jpeg: more bounds checking and skip malformed APP0
Also increase the maximum huffman symbols to 176
2025-09-08 17:13:03 +02:00
Hisham Aburaqibah 8644f3beba image/jpeg: better pack APP0 structs 2025-09-08 17:13:03 +02:00
Hisham Aburaqibah a6f18c3367 image/jpeg: implement jpeg decoding for baseline and extended sequential jpegs 2025-09-08 17:12:58 +02:00
Hisham Aburaqibah d704c45c24 core/image: some jpegs have APP13 or COM markers after SOI 2025-09-08 17:12:04 +02:00
Yuriy Grynevych 2bbd0a45c0 [core:time] time_js: tick_now(): Use f64 (was f32) as a return type of odin_env.tick_now(). 2025-09-08 17:57:28 +03:00
Jeroen van Rijn 21ce0c7ce9 Merge pull request #5660 from leecommamichael/master
[core:image/png] use .Image_Dimensions_Too_Large
2025-09-08 16:23:50 +02:00
Michael Lee cfde843778 [core:image/png] use .Image_Dimensions_Too_Large 2025-09-08 09:08:07 -05:00
Laytan 42c2cb89b5 Merge pull request #5658 from FourteenBrush/patch-3
Add build tags to `posix/spawn.odin`
2025-09-07 22:35:36 +02:00
FourteenBrush fe531c1888 Add build tags to posix/spawn.odin 2025-09-07 20:39:27 +02:00
gingerBill 0711806c21 Merge pull request #5653 from smoke-y/emptyParen
Fix compiler segfault when trying to use () as type
2025-09-06 12:23:48 +01:00
gingerBill a870dd3d69 Merge pull request #5654 from smoke-y/procType
Fix compiler segfault when trying to use proc at type level
2025-09-06 12:23:35 +01:00
gingerBill 38f308b348 Merge pull request #5656 from ekliot/vendor-box2d-bindings
`vendor:box2d` fix CreateMotorJoint proc signature
2025-09-06 12:23:21 +01:00
ekliot a6cd6dc265 fix CreateMotorJoint param type 2025-09-05 18:45:49 +01:00
smoke-y 5f60e7cdc0 formatting 2025-09-05 21:28:49 +05:30
smoke-y 906eddd1d4 formatting 2025-09-05 21:28:00 +05:30
smoke-y 5161731ce0 proc at type lvl seg fault 2025-09-05 11:27:28 +05:30
smoke-y c01ba41955 fix empty parentheses seg fault 2025-09-05 11:02:01 +05:30
FourteenBrush 9aabe75262 Add ERROR_NOT_FOUND
Returned by `CancelIoEx` when cancelled number or io completions was 0.
Was for some reason defined in `core:os`, but not in win32 pkg.
Ref: https://learn.microsoft.com/en-us/windows/win32/debug/system-error-codes--1000-1299-
2025-09-05 00:34:44 +02:00
Jon Lipstate 57bc45ae30 revert to working build 2025-09-03 22:51:28 -07:00
Jon Lipstate e0c4c53362 add tls when we have crt 2025-09-03 22:32:33 -07:00
FourteenBrush f6bf88d184 Add CancelIoEx to kernel32.odin 2025-09-04 00:38:51 +02:00
gingerBill 3bbf3641a1 Merge pull request #5648 from thetarnav/handle-allocator-error-in-read-entire-file
Handle allocator error when appending in read_entire_file_from_file
2025-09-02 15:49:42 +01:00
gingerBill 42cb1add91 Merge pull request #5645 from thetarnav/allocator-proc-require-results
Add require_results attr to procs returning an allocator
2025-09-02 15:47:27 +01:00
Damian Tarnawski cdca345d74 Handle optional allocator error when appending read bytes in read_entire_file_from_file 2025-09-02 13:42:25 +02:00
Damian Tarnawski 21fd7c200e Add require_results attr to procs returning an allocator 2025-09-02 13:03:15 +02:00
Jeroen van Rijn 7e3e15aee6 Merge pull request #5644 from AmedeoAlf/master
Specify %m and %M as verbs for integer formatting
2025-09-01 23:05:43 +02:00
AmedeoAlf 8bb597b9de Specify %m and %M as verbs for integer formatting 2025-09-01 22:44:24 +02:00
gingerBill ac93021ec9 Merge pull request #5643 from FourteenBrush/patch-2
Add `LPFN_GETACCEPTEXSOCKADDRS` to ws2_32.odin
2025-09-01 11:36:40 +01:00
FourteenBrush 10b7bba25d Add LPFN_GETACCEPTEXSOCKADDRS to ws2_32.odin 2025-08-31 23:52:00 +02:00
gingerBill 3ff58e00e4 Merge pull request #5634 from puugz/patch-1
Fix broken wglUseFontBitmaps binding
2025-08-31 11:56:08 +01:00
puugz ba279ec4ea Fix broken wglUseFontBitmaps binding 2025-08-30 18:31:46 +02:00
gingerBill b7a9113ac4 Merge pull request #5633 from kalsprite/fix_win_ole_api
fix typo in CLSIDFromProgIDEx signature
2025-08-30 14:47:31 +01:00
Jon Lipstate 94e1f30ebb fix typo in CLSIDFromProgIDEx signature 2025-08-29 14:35:34 -07:00
Jon Lipstate 231ce2da59 windows i386 support 2025-08-29 12:41:38 -07:00
gingerBill f926c1861f Merge pull request #5627 from A1029384756/master
skip errors on polymorphic procs when in a proc group with other options
2025-08-29 13:53:55 +01:00
Sam Mercer 30021e8dac Fix rbtree.find_or_insert
Update the existing node's value if the key is already present and align
documentation with behavior.
2025-08-29 11:02:30 +01:00
A1029384756 3074146784 skip errors on polymorphic procs when in a proc group with other options 2025-08-28 11:30:47 -04:00
gingerBill f7936419cd Merge pull request #5625 from StanislavNikolov/master
Fixed and added obj-c methods for NSWindow
2025-08-28 13:51:54 +01:00
Stanislav Ch. Nikolov ed389c188c Fixed and added obj-c methods for NSWindow 2025-08-28 12:39:15 +03:00
gingerBill 2f0b018db2 Merge pull request #5612 from Bazzas-Forks/master
Add `add/remove_document_event_listener()` to `core:sys/wasm/js`
2025-08-26 13:28:41 +01:00
gingerBill ac71a0aed1 Merge pull request #5617 from thetarnav/soa-resize-zero-memory
Zero existing memory when using resize_soa (fixes #5614)
2025-08-26 13:28:05 +01:00
Damian Tarnawski ce0cf7076c Add missing test attr and don't zero memory when reserve already did 2025-08-26 13:03:26 +02:00
gingerBill 83a78d5d28 Merge branch 'master' into soa-resize-zero-memory 2025-08-26 11:26:15 +01:00
gingerBill 0a02f5f076 Merge pull request #5616 from thetarnav/soa-allocator-resize
Support using allocator resize in `_reserve_soa` (fixes #5615)
2025-08-26 11:24:32 +01:00
Damian Tarnawski 95cfad67b7 Cleanup soa resize logic—reduce nesting 2025-08-24 15:17:13 +02:00
Damian Tarnawski 8a894c6ce6 More soa tests 2025-08-24 15:09:08 +02:00
Damian Tarnawski 66f4c93420 Handle nil old data case 2025-08-24 15:04:19 +02:00
Damian Tarnawski ac4a89e765 Always use .Resize_Non_Zeroed in _reserve_soa 2025-08-23 17:07:57 +02:00
Damian Tarnawski 2a6dfd2545 Avoid overlap issues when correcting memory after resize in _reserve_soa 2025-08-23 16:55:12 +02:00
Damian Tarnawski 18a2980d26 Zero existing memory when using resize_soa (fixes #5614) 2025-08-23 14:28:25 +02:00
Damian Tarnawski 9d651348b5 Only zero memory when requested 2025-08-23 13:10:19 +02:00
Damian Tarnawski 05706864b7 Support using allocator resize in _reserve_soa (fixes #5615) 2025-08-23 12:55:07 +02:00
gingerBill 2b6ed996be Merge pull request #5613 from GloriousPtr/queue_fix_caller_location
Propogate `#caller_location` to core:container/queue procs
2025-08-22 16:55:00 +01:00
gingerBill fbcd485b7e Merge pull request #5606 from thetarnav/sdl-ttf-require-results
Split SDL_ttf bindings to group with and without require_results
2025-08-22 16:54:25 +01:00
Mohit Sethi 27b59ab7c3 Propogate #caller_location to core:container/queue procs 2025-08-22 16:45:50 +01:00
gingerBill 9381040711 Fix parentheses for raddbg expression 2025-08-22 09:32:17 +01:00
gingerBill 46d4f22ef4 Remove debug print 2025-08-22 09:29:44 +01:00
gingerBill 23689d0c01 Improve the raddbg type views generated from fmt-based struct field tags 2025-08-22 09:29:07 +01:00
Bailey Gibbons 26d066d369 Add add/remove_document_event_listener() to core:sys/wasm/js 2025-08-22 15:34:50 +10:00
gingerBill d5b1fc48fb Add @(raddbg_type_view=<optional-string>)
If no string parameter is provided, then one will be generated from the struct field tags.
The attribute must be applied if the automatic struct field tag approach is to be used.
2025-08-21 17:14:33 +01:00
Laytan 0c9e1f5807 Merge pull request #5607 from blob1807/fix-wasm-simd-mem-equal
Fix stride in `memory_equal/compare_zero` giving false positves
2025-08-20 21:47:56 +02:00
blob1807 f90d7029b4 Fix stride in memory_equal/compare_zero giving false positves
The previous stride of 8 assumed `uintptr` size is 8 which isn't the case on 32bit & wasm64p32. Skipping every other set of 4 bytes
2025-08-21 05:19:16 +10:00
Damian Tarnawski 2485238592 Split SDL_ttf bindings to group with and without require_results 2025-08-20 20:18:19 +02:00
gingerBill 06179fc736 Merge pull request #5599 from BradLewis/fix/file-tag-eof
Check for EOF when scanning file tags
2025-08-19 12:58:29 +01:00
Brad Lewis 8bab146b2d Check for EOF when scanning file tags 2025-08-19 07:20:31 -04:00
gingerBill 409e397566 Fix bug with $fn: proc() when passed with a global variable 2025-08-18 21:47:09 +01:00
gingerBill f8b56ccd88 Update stb_truetype.c again 2025-08-18 15:51:11 +01:00
gingerBill a0f6084b48 Rebuild stb libraries and compile stb_truetype using the stb_rect_pack rects 2025-08-18 14:26:52 +01:00
gingerBill ebd26135e8 Merge pull request #5596 from alessio98888/master
Fix buddy allocator assert
2025-08-18 12:38:02 +01:00
gingerBill e0a9b23f02 Merge pull request #5597 from connnnal/d3d12-min-precision
Make D3D12_FEATURE_DATA_D3D12_OPTIONS.MinPrecisionSupport a bitset
2025-08-18 12:28:35 +01:00
connnnal 17f9ad29af Make D3D12_FEATURE_DATA_D3D12_OPTIONS.MinPrecisionSupport a bitset
https://learn.microsoft.com/en-us/windows/win32/api/d3d12/ns-d3d12-d3d12_feature_data_d3d12_options
2025-08-17 18:35:25 +01:00
alessio98888 c6db3cc670 Fix buddy allocator assert
The last address of "data" is not "cast(uintptr)raw_data(data)+cast(uintptr)size" but
"cast(uintptr)raw_data(data)+cast(uintptr)(size-1)".

The original assert would fail when for example the allocation size requested and the buddy allocator allignment were both 64.
2025-08-16 19:50:06 +02:00
gingerBill fb46413071 Merge pull request #5590 from leecommamichael/master
[vendor:OpenGL] fix misnamed parameter
2025-08-16 09:06:25 +01:00
Michael Lee fbac18ec00 missed a spot 2025-08-15 11:12:30 -05:00
Michael Lee c4102701fd misnamed parameter 2025-08-15 11:04:00 -05:00
gingerBill d1ce7f8fe6 Merge pull request #5516 from cardboardguru76/darwin-foundation-support-for-handmade-hero-port
Additional obj-c methods for darwin Foundation
2025-08-15 12:13:27 +01:00
gingerBill 6d68488a50 Merge pull request #5533 from weskerfoot/add-missing-xlib-proc
add missing xlib functions for getting and setting text properties
2025-08-15 12:12:36 +01:00
gingerBill 977e971c8b Merge pull request #5581 from Xotchkass/rand-cleanup
Cleanup in `math/rand` and `runtime/random_generator`
2025-08-15 12:12:17 +01:00
gingerBill 7577bfc28b Merge pull request #5582 from diniamo/fix-itimer-flags
Fix ITimer_Flags_Bits enum value
2025-08-15 12:11:28 +01:00
gingerBill aff96e7d3f Merge pull request #5583 from slowhei/master
Fix Typo in `Device_newBufferWithSliceNoCopy`
2025-08-14 15:46:22 +01:00
Tohei Ichikawa bc78aad45f Fix typo in newBufferWithSliceNoCopy 2025-08-14 09:56:36 -04:00
diniamo 88dba1194a Fix ITimer_Flags_Bits enum value 2025-08-14 15:01:42 +02:00
Xotchkass d60fba13df fix: throwing away the last generated byte in default_random_generator_proc 2025-08-14 13:49:59 +03:00
Xotchkass 2d5652dbd4 remove private _random_u64 and move it's functionality into public uint64 2025-08-14 13:39:18 +03:00
Xotchkass df849891c1 use runtime.random_generator_read_bytes in read procedure instead of filling it manually. 2025-08-14 13:35:25 +03:00
gingerBill 71e992d5bf Merge pull request #5579 from wrathdoesthat/master
Added getaddrinfo flags
2025-08-13 17:17:39 +01:00
Wrath b6a0606c98 Added getaddrinfo flags 2025-08-12 19:59:38 -04:00
gingerBill 2648bd8fcd Allow #+feature global-context for @(init) and @(fini) procedures as an interim measure 2025-08-12 09:51:16 +01:00
gingerBill 8df69c95c3 Add -integer-division-by-zero:all-bits 2025-08-10 18:29:08 +01:00
gingerBill b6e0b48481 Rename block names from div to mod. 2025-08-10 17:58:46 +01:00
gingerBill 4cbcb3ace7 Add shortcut for unsigned_x/power_of_two -> unsigned_x >> log2(power_of_two) 2025-08-10 17:53:07 +01:00
gingerBill da76c743e9 Add shortcut for division by a constant 2025-08-10 17:42:49 +01:00
gingerBill ecb6b35da5 Fix name canonicalization for named specialized forms 2025-08-10 15:29:53 +01:00
gingerBill 983f3ec423 Add #+feature global-context
This allows to use of `context` in the global scope on a per file basis.
2025-08-10 15:03:30 +01:00
gingerBill 1524b40bc9 Merge pull request #5556 from odin-lang/bill/division-by-zero
Define Integer Division By Zero
2025-08-10 14:48:33 +01:00
gingerBill a0ff05e633 Merge pull request #5558 from odin-lang/bill/init-fini-changes
`@(init)` & `@(finit)` Changes.
2025-08-10 12:47:15 +01:00
gingerBill dbc338248e Merge pull request #5567 from alexriedl/webgl-binding-fixes
Webgl binding fixes
2025-08-10 12:44:36 +01:00
Alex Riedl a8dca3920e Merge branch 'master' of github.com:odin-lang/Odin 2025-08-09 10:47:09 -05:00
Alex Riedl 277c6cac71 Fix some webgl bindings 2025-08-09 10:47:07 -05:00
ed aed7a29e3d update type_kinds.hpp based on latest merge 2025-08-09 10:04:31 -04:00
ed 72275ae90c Merge tag 'dev-2025-08'
# Conflicts:
#	.gitignore
2025-08-09 09:50:50 -04:00
Jeroen van Rijn d3736d765a Merge pull request #5564 from janga-perlind/pr/group-check
Do not check for explicit allocators when determining proc in proc group
2025-08-09 05:03:39 +02:00
janga-perlind 5db6ea8354 Do not check for explicit allocators when determining proc in proc group 2025-08-09 12:37:15 +10:00
gingerBill 14ca1c8c89 Add another contextless 2025-08-08 15:41:44 +01:00
gingerBill 786d454443 Merge pull request #5559 from Creativty/variable_dereference_suggestion
Improve dereference missing suggestion message
2025-08-08 15:34:45 +01:00
xenobas 443dd566e3 Add a better suggestion for cases that don't need ^ operator 2025-08-08 14:40:43 +01:00
gingerBill 0f5ced52a0 Assign context in scope 2025-08-08 13:42:48 +01:00
gingerBill 804984ed35 contextless fixes for js 2025-08-08 13:29:49 +01:00
gingerBill 7c93a5ae80 Add missing contextless 2025-08-08 13:16:20 +01:00
gingerBill 8ff15eaf69 More contextless fixes 2025-08-08 13:02:37 +01:00
gingerBill aa747a1c10 Add more "contextless" 2025-08-08 12:55:23 +01:00
gingerBill a0462aa8d7 Fix test for global procedure initialization 2025-08-08 12:49:24 +01:00
gingerBill 78290ceef3 Add contextless to another proc 2025-08-08 12:38:20 +01:00
gingerBill 0c7260e701 Update src/main.cpp
Co-authored-by: Itzik Shneorson <35134559+itziksn@users.noreply.github.com>
2025-08-08 12:37:36 +01:00
gingerBill 414b1059a8 Fix typo 2025-08-08 12:36:56 +01:00
gingerBill d381d0ece4 Fix more procedure to be contextless 2025-08-08 12:33:34 +01:00
gingerBill d3f649d244 Make get_args contextless 2025-08-08 12:25:58 +01:00
gingerBill 06e48099ca Improve error message 2025-08-08 12:23:22 +01:00
gingerBill b86932c03c Disallow proc "odin" procedures to be called in the global scope in variable declarations 2025-08-08 12:21:50 +01:00
gingerBill 8b860da2eb Remove unused import 2025-08-08 12:12:08 +01:00
gingerBill 7642e0a0e0 Require @(init) and @(fini) to be proc "contextless" () 2025-08-08 12:10:01 +01:00
gingerBill b8ad150767 Merge pull request #5555 from flysand7/runtime-doc-update
Update runtime doc file
2025-08-08 11:16:54 +01:00
gingerBill 8c1eda3e3a Handle fixed_point_div and fixed_point_div_sat 2025-08-08 11:10:01 +01:00
gingerBill 7b5cee9f1e Correct #+feature check 2025-08-08 10:50:24 +01:00
gingerBill ee01643229 Add -integer-division-by-zero:self 2025-08-08 10:41:05 +01:00
gingerBill 991883d0e1 Add #+feature integer-division-by-zero:<string> 2025-08-08 10:24:44 +01:00
gingerBill e4a0228a80 Define the behaviour of integer division by zero 2025-08-08 10:00:11 +01:00
Sunagatov Denis e6635e2508 Update runtime doc file
This updates and reformats the doc file for the runtime package. The
list of things that need to be implemented for a compiler runtime to
work has been updated in accordance with recent changes to runtime
(notably `cstring16` and `string16` types and `#load_directory`). Some
copy-paste errors around string-comparison procedures have been fixed.

The file has been renamed to `doc.odin` as per convention, the comment
has been moved to the top of the package declaration and the comment is
now markdown-formatted.

Also wrote down a little map to maybe slightly help with understanding
navigation within package runtime's files and added a few more
explanations as to why that list of declarations exists and how to use
it.

The list of declarations has been detailed to some degree, explaining
under what conditions the declarations are required.
2025-08-08 15:34:30 +11:00
Jeroen van Rijn 3194fda8f3 Merge pull request #5554 from flysand7/ice-fix
Print the name of missing runtime procedure
2025-08-07 20:07:55 +02:00
Sunagatov Denis c22da490b9 Print the name of missing runtime procedure
This continues the fix made at 46b7abee9f,
by asserting on missing entity early and printing it's name if its not
found.
2025-08-08 04:56:59 +11:00
gingerBill 2e4837bf37 Merge branch 'master' of https://github.com/odin-lang/Odin 2025-08-07 17:54:25 +01:00
gingerBill b6944b8acb Fix instantiation of package for parapoly records 2025-08-07 17:54:17 +01:00
Jeroen van Rijn d612f6ec07 Merge pull request #5553 from flysand7/ice-fix
Fix ICE on missing procedure in base:runtime
2025-08-07 18:44:09 +02:00
Sunagatov Denis 46b7abee9f Fix ICE on missing procedure in base:runtime
When a required built-in procedure is missing from the base:runtime
package, an assert should be triggered. However this does not happen
and instead the compiler crashes silently. The cause is the
null-dereference after scope_lookup_current returns nullptr.

This adds an assertion that the runtime procedure is found, before
proceeding to check it's type and performing further lookups.
2025-08-08 03:30:15 +11:00
gingerBill e16f90f958 Merge pull request #5549 from slowhei/master
Fix Incorrect/Missing Metal Mesh Shading Bindings
2025-08-07 16:09:42 +01:00
gingerBill a0e9a98d61 Merge pull request #5547 from harold-b/hb.objc_block_intrinsic
Implements the Apple block ABI.2010.3.16 natively via `objc_block` intrinsic
2025-08-07 16:08:38 +01:00
gingerBill 098d8cae9b Merge pull request #5551 from connnnal/d3d-strings
Alias [^]u16 to Windows LPCWSTR
2025-08-07 13:22:40 +01:00
connnnal 3a1171e25f Alias [^]u16 to Windows LPCWSTR 2025-08-07 13:15:12 +01:00
gingerBill 1470c300c7 Add support for [dynamic]T in .raddbg 2025-08-07 12:45:59 +01:00
gingerBill d6bd1f144f Merge branch 'master' of https://github.com/odin-lang/Odin 2025-08-07 12:38:57 +01:00
gingerBill 3de300d2f9 Fix typo 2025-08-07 12:38:15 +01:00
gingerBill 34b4b84b64 Add intrinsics.type_canonical_name 2025-08-07 12:34:41 +01:00
Tohei Ichikawa 5a998d44d4 Add bindings for vertexLinkedFunctions 2025-08-07 00:25:36 -04:00
Tohei Ichikawa a492fa7bc2 Fix Metal mesh shading bindings 2025-08-06 23:56:36 -04:00
Harold Brenes 9d8e15b3af Implementes the block ABI.2010.3.16 natively via the objc_block intrinsic and the Objc_Block builtin type.
See: https://clang.llvm.org/docs/Block-ABI-Apple.html
2025-08-06 20:27:31 -04:00
gingerBill 09a1e170bc Merge pull request #5530 from odin-lang/bill/utf16-strings
UTF-16 string types: `string16` & `cstring16`
2025-08-06 16:09:18 +01:00
Laytan Laats ec75094303 remove windows binaries from non-windows releases 2025-08-05 21:31:06 +02:00
Laytan e0a08de455 Merge pull request #5537 from A1029384756/master
[ci:nightly] added linux arm build
2025-08-05 20:36:11 +02:00
gingerBill af3184adc9 Change is_utf16 field to encoding and use an enum 2025-08-05 15:12:54 +01:00
gingerBill eae43f1225 Merge branch 'master' into bill/utf16-strings 2025-08-05 15:07:06 +01:00
gingerBill accdd7c2af Fix atomics for tuples 2025-08-05 12:31:57 +01:00
gingerBill a675784999 Merge branch 'master' of https://github.com/odin-lang/Odin 2025-08-05 12:28:24 +01:00
gingerBill 7f194080e6 Fix possible race condition with struct offsets 2025-08-05 12:28:18 +01:00
Laytan b022c020f3 Merge pull request #5540 from jared-cone/fix-windows-delete-after-free
Fixed delete-after-free in file_windows.odin
2025-08-05 07:10:23 +02:00
Laytan 8e354a2afd Merge pull request #5539 from Jack-Punter/fix-spall-scoped-event-with-autotracing
Adds @(no_instrumentation) to spall buffer and SCOPED operations
2025-08-05 07:10:12 +02:00
Jared Cone b1cda52fd6 Fixed delete-after-free in file_windows.odin 2025-08-04 19:42:23 -07:00
Jack Punter 45e4ce5d44 Adds @(no_instrumentation) to spall buffer and SCOPED operations
Currently without this scoped event names are not displaying correctly when auto-tracing is enabled.
The buffer_destroy event, obviously, fails to be completed (as theres no buffer to write the end event to, and context_destroy should happen after all the buffers are destroyed so there's, again, no buffers to write to.
2025-08-04 23:15:16 +01:00
gingerBill c910b5e583 Add intrinsics.type_is_nearly_simple_compare 2025-08-04 12:13:30 +01:00
A1029384756 70818030f6 [nightly] added linux arm build
[nightly] docker container for linux arm

[nightly] removed setup-alpine for arm

[nightly] docker container for all linux + linux arm dep for upload

[nightly] x86 remove arm reference

[nightly] final fixes
2025-08-04 00:45:00 -04:00
Wesley Kerfoot a9e9e88f06 add missing xlib functions for getting and setting text properties 2025-08-03 11:34:54 -04:00
gingerBill 4fac64afd4 Merge pull request #5531 from laytan/thread-stack-size-rlimit
thread: set stack size to rlimit
2025-08-02 14:58:33 +01:00
Laytan Laats 25389ed086 thread: set stack size to rlimit 2025-08-02 15:22:23 +02:00
gingerBill f8d24923fd Fix cstring != "" 2025-08-02 13:23:20 +01:00
gingerBill 86bd9186f9 Fix string16 != "" comparison 2025-08-02 13:17:31 +01:00
gingerBill dca9bf0b0c Fix string16 literal length set in LLVM 2025-08-02 13:11:34 +01:00
gingerBill e049dde582 Fix tests for UTF-16 strings 2025-08-02 13:01:58 +01:00
gingerBill 5aec40e3e0 Remove unneeded uses of intrinsics.constant_utf16_cstring 2025-08-02 12:55:05 +01:00
gingerBill 7c281a9614 Fix [^]u16 <-> cstring16 conversions 2025-08-02 12:51:08 +01:00
gingerBill c631a8eff5 os2 internals -> (c)string16 2025-08-02 12:47:03 +01:00
gingerBill 9b5700225d Add string16_map.cpp 2025-08-02 12:33:33 +01:00
gingerBill 620bf162a0 Cache const string16 in LLVM 2025-08-02 12:32:18 +01:00
gingerBill bb4bc316a4 for in string16; Support string16 across core 2025-08-02 12:20:35 +01:00
gingerBill ae02d3d02d Begin supporting string16 across the core library 2025-08-02 11:55:16 +01:00
gingerBill 2561427dd3 Add string16 and cstring16 (UTF-16 based strings) 2025-08-02 11:00:15 +01:00
Steve Waddicor 9dfce3da86 Convert leading spaces to tabs 2025-08-01 23:06:04 +01:00
Laytan 710203eadb Merge pull request #5505 from RoboMage/sdl2_audio_bitset
SDL2 - AudioAllowChangeFlags bit_set
2025-08-01 23:46:26 +02:00
Laytan a7a6216e08 Merge pull request #5510 from taylormck/add-cgltf-enums
add cgltf filter type and wrap mode enums
2025-08-01 23:46:13 +02:00
Laytan d343b93ef2 fix check 2025-08-01 20:31:53 +02:00
Laytan 20318e7a3b concrete types to make llvm 14 happy
Fixes #5463
Fixes #5244
Fixes #5435
2025-08-01 19:27:28 +02:00
Laytan d0890c2135 fix dropping part of particular vecs 2025-08-01 19:18:43 +02:00
gingerBill 3eb9c5fa65 Merge pull request #5525 from Barinzaya/xxh3-simd
`core:hash/xxhash`: Static SIMD Support for XXH3
2025-08-01 16:22:29 +01:00
gingerBill ab866653a8 Merge pull request #5526 from laytan/fixes-for-vector-abi
amd64 abi fixes regarding vectors
2025-08-01 16:21:44 +01:00
Barinzaya 4ef7ed1cbd Skip bounds checking on the inner accumulate loop.
This helps performance with SSE (somewhat) and AVX-512 (quite a bit),
but not AVX2 for some reason.
2025-07-31 16:51:42 -04:00
Laytan 5527982c20 fix vec offset calculation 2025-07-31 22:01:17 +02:00
Laytan f32ee28e6d amd64 support half in the abi too 2025-07-31 20:50:46 +02:00
Laytan c3bae964d0 amd64 abi fixes regarding vectors
- Fixes the code so SSEUp is grouped/skipped over properly (Fixes #5429)
- Fixes f16 vectors using garbage widths, because it would call
LLVMGetIntTypeWidth and an f16 is not an int so doesn't have that
function
2025-07-31 20:26:22 +02:00
Barinzaya f61dc7d071 Remove favor_size attributes inhibiting SIMD optimizations.
This makes a tremendous (2x with SSE2, 3x with AVX2) difference on big
datasets on my system, but this may be hardware-dependent (e.g.
instruction cache sizes).

Naturally, this also results in somewhat larger code for the large-data
case (~75% larger).
2025-07-31 13:05:10 -04:00
Barinzaya 2f8b390c19 Various minor changes in XXH3.
This includes various minor things that didn't seem right or could be
improved, including:
- XXH3_state is documented to have a strict alignment requirement of 64
  bytes, and thus came with a disclaimer not to use `new` because it
  wouldn't be aligned correctly. It now has an `#align(64)` so that it
  will.
- An _internal proc being marked #force_no_inline (every other one is
  #force_inline)
- Unnecessarily casting the product of two u32s through u128 (and
  ultimately truncating to u64 anyway)
2025-07-31 13:05:10 -04:00
Barinzaya 9d40f371be Add static SIMD support to XXH3 in core:hash/xxhash.
This uses compile-time features to decide how large of a SIMD vector to
use. It currently has checks for amd64/i386 to size its vectors for
SSE2/AVX2/AVX512 as necessary.

The generalized SIMD functions could also be useful for multiversioning
of the hash procs, to allow for run-time dispatch based on available CPU
features.
2025-07-31 13:05:08 -04:00
Jeroen van Rijn 393e00bec3 Placate linker 2025-07-31 16:40:40 +02:00
Jeroen van Rijn a41500de28 Merge pull request #5520 from Mecso2/master
fix amd64 no-crt entry assembly
2025-07-31 16:38:21 +02:00
gingerBill 077ba0b6cb Merge pull request #5513 from colrdavidson/spall_v3
update to spall format v3
2025-07-31 12:37:09 +01:00
gingerBill 9b8223dd69 Remove use of .no_copy 2025-07-30 23:19:14 +01:00
gingerBill 6a10cfdc30 Fix typo 2025-07-30 23:15:14 +01:00
gingerBill a2e7a62a26 Add virtual.new_clone 2025-07-30 23:14:53 +01:00
gingerBill 7057fc8dfc Remove the semantics of #no_copy, keep the grammar 2025-07-30 23:14:29 +01:00
gingerBill aa6a749804 Improve atomic logic for sync.Wait_Group 2025-07-30 23:11:18 +01:00
Colin Davidson 3e10684630 adjust scale with new format, fix segfault for auto-trace 2025-07-30 14:09:50 -07:00
Colin Davidson 7720a32120 Merge remote-tracking branch 'live/master' into spall_v3 2025-07-30 12:51:56 -07:00
Mecso2 e54bf24746 fix amd64 no-crt entry assembly 2025-07-30 12:44:53 +02:00
Laytan 939fed592d Merge pull request #5517 from colrdavidson/freq_hotfix
fix x86 osx build
2025-07-30 06:22:25 +02:00
cardboardguru76 44f039a92f Merge branch 'odin-lang:master' into darwin-foundation-support-for-handmade-hero-port 2025-07-30 00:28:31 +01:00
Colin Davidson b5a8a3cf94 require to reduce files for a one line function 2025-07-29 13:58:30 -07:00
Colin Davidson 42f2891f35 attempt to fix x86 osx build 2025-07-29 13:54:56 -07:00
Colin Davidson e869b9351b Merge remote-tracking branch 'live/master' into spall_v3 2025-07-29 13:48:32 -07:00
Laytan 861fa4ab68 Merge pull request #4140 from colrdavidson/macharena
Mach Process control
2025-07-29 22:37:42 +02:00
Colin Davidson 35a95fc3e4 workaround to avoid excessive file-splitting 2025-07-29 13:28:04 -07:00
Colin Davidson 517e392abe if -> when 2025-07-29 13:18:40 -07:00
Colin Davidson 4d9fdf5bd3 move to checker error, rather than panic 2025-07-29 13:09:05 -07:00
Steve Waddicor 9c5e577792 Additional obj-c methods for darwin Foundation
Added support for NSBitmapImageRep class.
Added ability to set contents to a CALayer.
I needed these to support a port of Handmade Hero, but they are of general use.
2025-07-29 21:01:22 +01:00
Colin Davidson 9a2e6fff48 switch to read_cycle_counter_frequency from arm64_read_cycle_counter_freq, trap on invalid arch 2025-07-29 12:21:46 -07:00
Colin Davidson c1b3d035e4 remove spawn from os, comment sys/posix/spawn 2025-07-29 12:12:15 -07:00
Colin Davidson 0a102bd757 shuffle to Kern_Return 2025-07-29 11:52:58 -07:00
Colin Davidson fe2b48dec4 enum pass 2025-07-29 11:48:58 -07:00
Laytan 435f7f6503 Merge pull request #5515 from laytan/ignored-arg-multi-return
fix ignored args in multi return handling
2025-07-29 19:16:32 +02:00
Laytan e8a591386b Merge pull request #5514 from laytan/saner-default-stack-linker-flags
saner stack linker flags for WASM
2025-07-29 19:16:19 +02:00
Laytan af0b90bd3e fix flag 2025-07-29 19:07:28 +02:00
Laytan c966e63520 fix ignored args in multi return handling
Fixes #5483
2025-07-29 19:04:49 +02:00
Laytan e7670e58dd saner stack linker flags for WASM
Supersedes #5425
2025-07-29 18:50:27 +02:00
Taylor 6c2b72f701 fix: align the enum values 2025-07-30 00:17:40 +09:00
Colin Davidson b5629aeed9 copy-paste typo fix 2025-07-28 16:34:53 -07:00
Colin Davidson 1a9b128bfc update linux-arm to use the asm intrin for freq 2025-07-28 16:32:10 -07:00
Colin Davidson e1fd69f573 oops, one more manual_header 2025-07-28 16:27:54 -07:00
Colin Davidson 7986d85924 name_container_event -> name_event 2025-07-28 16:25:42 -07:00
Colin Davidson 2dd1e3c8e3 fix casts and consts 2025-07-28 16:24:29 -07:00
Colin Davidson 5b020591d8 update to spall format v3 2025-07-28 16:19:51 -07:00
Colin Davidson 76b00c046b arm64 has an invariant tsc too 2025-07-28 15:30:24 -07:00
Colin Davidson 1848e0df05 use the correct frequency for the arm tsc timer 2025-07-28 15:10:42 -07:00
Colin Davidson b88f9194d0 Merge remote-tracking branch 'live/master' into macharena 2025-07-28 14:24:46 -07:00
Taylor 1b15c9928b add cgltf filter type and wrap mode enums 2025-07-28 23:28:19 +09:00
gingerBill be3006dbf2 Merge pull request #5507 from Paul-Andre/fix-issue-5474
Fix issue 5474
2025-07-28 11:42:09 +01:00
Paul-Andre Henegar 93a39affd1 Fix issue 5474
The fix was adding `is_constant = false;`

I also removed the unnecessary check regarding the first element of the
BitSet, since it's checked inside the loop, and also fixed a typo in the
message.
2025-07-28 01:42:19 -04:00
robomage 55de1dd923 SDL2 - audio allow change bit_set
sdl.OpenAudioDevice was incorrectly using a bool instead of a c.int for it's last parameter. To make the proc call more idiomatic and inline with other bindings a new bit_set was introduced to be used in place of the constants
2025-07-27 17:39:42 -04:00
Jeroen van Rijn a93d3503b1 Merge pull request #5499 from Kelimion/fix-5498
Fix #5498
2025-07-25 12:09:34 +02:00
Jeroen van Rijn 3a7e4873cd Fix #5498
Also:
- Expands `tests/core/hash`
- Fixes bug found in `#hash(s, "murmur64")`
2025-07-25 12:00:24 +02:00
Jeroen van Rijn 315cd51f76 Merge pull request #5491 from Feoramund/buddy-2
Fix Linux-specific optimized test failure
2025-07-22 17:01:13 +02:00
Feoramund a0efdf26a6 mem: Clarify Buddy_Allocator requirements 2025-07-22 10:52:55 -04:00
Feoramund 58f32cd690 Fix Linux-specific optimized test failure
The stack was not aligned as expected for `buddy_allocator_init` when
`-o:speed` was enabled, making this a test failure that only appeared
with optimizations enabled.

The data is now aligned specifically, as it should be.
2025-07-22 10:40:16 -04:00
gingerBill 19a075211f Merge pull request #5442 from jon-lipstate/table_lookup
table lookup simd intrinsic
2025-07-22 11:14:54 +01:00
gingerBill 513e6daace Merge pull request #5081 from Lperlind/vet-explicit-allocators
Add -vet-explicit-allocators
2025-07-22 11:06:12 +01:00
gingerBill e2b75d2add Merge pull request #5473 from harold-b/hb.subtarget-enhancements
Check for invalid subtargets and add "ios" pseudo subtarget
2025-07-22 11:01:50 +01:00
Harold Brenes 7c917d56e9 Check for invalid subtargets.
- Add 'ios' pseudo-subtarget which triggets with either iPhone or iPhoneSimulator subtargets.

- Treat an explicit 'default' subtarget as exclusive only to the default subtarget, not an other platform-compatible subtargets.

- 'generic' continues to resolve to true for any platform-compatible subtarget as it names appears to imply such behavior.
2025-07-20 14:35:06 -04:00
gingerBill b095dd71cb Merge branch 'master' of https://github.com/odin-lang/Odin 2025-07-20 15:32:28 +01:00
gingerBill 0dd0a3813b Fix very subtle bug in virtual.memory_block_alloc 2025-07-20 15:32:22 +01:00
gingerBill 98c2425fe0 Merge pull request #5467 from harold-b/hb.ios-subtarget-rename-iphone
Rename `iOS` subtarget to `iPhone`, add `ODIN_PLATFORM_SUBTARGET_IOS`
2025-07-20 13:22:47 +01:00
Laytan a90ee53866 Merge pull request #5485 from poops/sdl3-image-save-functions-return-bool
SDL_image save functions should return bool
2025-07-20 13:18:09 +02:00
Laytan a658cc5ef6 Merge pull request #5482 from sergeypdev/master
Disable filepath/match.odin and filepath/walk.odin compilation on js targets
2025-07-20 13:17:10 +02:00
Laytan 089d8a229c Merge pull request #5479 from wisonye/master
Fixed Index 0 is out of range 0..<0' when using '-default-to-nil-allocator' for FreeBSD/OpenBSD/NetBSD/Linux
2025-07-20 13:12:45 +02:00
Jeroen van Rijn 50358380ae Merge pull request #5484 from laytan/hash-bytes-to-buffer-up-to-digest-size
crypto/hash: hash_bytes_to_buffer slice result to digest size
2025-07-20 03:14:54 +02:00
brandon e7e16f063e SDL_image save functions should return bool 2025-07-19 18:51:51 -04:00
Laytan 164bb52212 crypto/hash: hash_bytes_to_buffer slice result to digest size 2025-07-19 19:50:32 +02:00
sergeypdev 2fc8ca6cf5 Disable filepath/match.odin and filepath/walk.odin compilation on js
targets
2025-07-19 16:44:45 +04:00
ed c1edaf54d8 dumb mistake 2025-07-19 00:38:51 -04:00
ed fe78247063 add plex 😏 2025-07-19 00:38:06 -04:00
ed 747098efaf Support for using on procedure struct typed arguments 2025-07-18 23:48:32 -04:00
WisonYe 4ccdb48044 Fixed the build check: ('arg' declared but not used) against the '-default-to-nil-allocator' fix for FreeBSD/OpenBSD/NetBSD/Linux. 2025-07-19 12:29:03 +12:00
WisonYe b9f08412ae Fixed Index 0 is out of range 0..<0' when using '-default-to-nil-allocator' for Linux/OpenBSD/NetBSD. 2025-07-19 12:03:22 +12:00
WisonYe 26e4104ac9 Fixed 'Odin/core/os/os_linux.odin(1104:7) Index 0 is out of range 0..<0' when using '-default-to-nil-allocator'. 2025-07-19 11:59:18 +12:00
WisonYe 80cd080175 Fixed 'Odin/core/os/os_freebsd.odin(971:7) Index 0 is out of range 0..<0' when using '-default-to-nil-allocator'. 2025-07-19 11:54:17 +12:00
gingerBill a19e7845b1 Merge pull request #5472 from harold-b/hb.auto_objc_name
Allow objective-c procedures to have their `@objc_name` attribute inferred
2025-07-17 21:01:28 +01:00
gingerBill 28053a0ff0 Merge pull request #5475 from connnnal/iunknown-uuid
Add IUnknown UUID
2025-07-17 11:59:42 +01:00
gingerBill 1ef0f1be6b Merge pull request #5476 from jon-lipstate/card_hint
add did you mean for card/len
2025-07-17 11:36:53 +01:00
Jon Lipstate 6c81df82a6 cleanup langauge / errors about table vs swizzle 2025-07-16 23:43:41 -07:00
Jon Lipstate 3e5de5f705 add did you mean for card/len 2025-07-16 23:23:11 -07:00
Jon Lipstate ecd41b155d rename table_lookup to runtime_swizzle 2025-07-16 21:54:24 -07:00
connnnal f6993a8205 Add IUnknown UUID 2025-07-17 05:00:20 +01:00
Harold Brenes edc01293b2 Allow objective-c procedures to have their @objc_name attribute inferred.
The `@objc_name` is automatically inferred if it is not specified and
the procedure name is prefixed with type name specified in `@objc_type`,
followed by an `_`. What followed the `_` is interpreted as the `@objc_name`.
2025-07-16 17:14:57 -04:00
gingerBill e8b2f1eeaa Fix indentation 2025-07-16 15:25:05 +01:00
gingerBill e5baf483fd Update vendor:kb_text_shape to v1.03 2025-07-16 15:14:41 +01:00
gingerBill e21892ce89 Merge pull request #5471 from harold-b/hb.fix_objc_class_method_impl
Fix @objc_implement methods not respecting @objc_is_class_method
2025-07-16 11:38:02 +01:00
Harold Brenes efe4f40974 Fix @objc_implement methods not respecting @objc_is_class_method
Fix incorrect type encoding for objc_class
2025-07-15 23:47:13 -04:00
Harold Brenes 63b9cb18ef Missing rename in panic string 2025-07-14 22:32:06 -04:00
Harold Brenes bab4ce11fc Rename iOS subtarget to iPhone for consistency.
Add `ODIN_PLATFORM_SUBTARGET_IOS` builtin constant which evaluated to
`true` when the platform is `Darwin` and the subtarget it either `iPhone` or `iPhoneSimulator`
2025-07-14 21:55:28 -04:00
Laytan 204edd0fc2 Merge pull request #5459 from harold-b/hb.simplify-import-odin-ext-folders-check
Use `fi.is_dir` instead of `path_is_directory()` during directory check when collecting .odin files
2025-07-14 21:59:05 +02:00
Laytan 67c90b5d9e Merge pull request #5466 from harold-b/hb.fix-ios-simulator-triplet
Fix correct versioned target triplet for iphonesimulator subtarget
2025-07-14 20:51:00 +02:00
Harold Brenes 77e5c71414 Fix correct versioned target triplet for iphonesimulator subtarget
- Always set the `-m*-version-min` linker flag for non-macOS Darwin subtargets
2025-07-14 14:28:07 -04:00
gingerBill 02e5dc9948 Merge pull request #5465 from harold-b/hb.ios-min-version-linker-fix
Provide default minimum version for iOS and apply its target triplet.
2025-07-14 18:11:28 +01:00
Harold Brenes 070943aa98 Provide default minimum version for iOS and apply its target triplet.
- Fix incorrect clang_path override for iOS during link stage.
2025-07-14 12:59:25 -04:00
gingerBill 362c146f9d Merge pull request #5462 from harold-b/hb.ios-support-2025
Add iOS & iPhoneSimulator subtargets for Darwin target
2025-07-14 16:50:57 +01:00
gingerBill 924d29208d Merge pull request #5460 from harold-b/hb.objc_ivars-indent-fix
Fix leftover poor indentation for objc_ivars MPSCQueue
2025-07-14 11:44:37 +01:00
Harold Brenes 4d2d890b4c Fix accidental incorrect assignment 2025-07-13 20:29:54 -04:00
Harold Brenes 0e245fb40f Updated iOS/iPhoneSimulator build support 2025-07-13 20:17:30 -04:00
Harold Brenes 219b0fe535 Replace system:System.framework imports with system:System
This makes the linker work for both macOS and iOS targets
2025-07-13 15:45:21 -04:00
Harold Brenes 9a87611609 Fix leftover poor indentation for objc_ivars MPSCQueue 2025-07-13 15:39:41 -04:00
Harold Brenes b811414ed1 Use fi.is_dir instead of path_is_directory() when checking if an import is a directory with a .odin extension. 2025-07-13 15:24:53 -04:00
ed c3da99eac5 Merge tag 'dev-2025-07' 2025-07-12 22:38:51 -04:00
gingerBill 843c39189e Merge pull request #5455 from FourteenBrush/master
Add `type_enum_is_contiguous` intrinsic (Closes #5395)
2025-07-12 23:19:33 +01:00
FourteenBrush 980370a24b Add union kind assertion to enum_constant_entity_cmp 2025-07-11 21:23:21 +02:00
FourteenBrush d08ebf56e7 Add intrinsics.type_enum_is_contiguous test 2025-07-11 21:10:42 +02:00
FourteenBrush 2dd0b75289 Fix BigInt leaking 2025-07-11 21:07:28 +02:00
gingerBill 38faec757d Correct consume comment groups in both parsers 2025-07-11 18:41:40 +01:00
FourteenBrush 64bb0d1c7d Allocate temp array instead of sorting in place 2025-07-11 19:38:01 +02:00
FourteenBrush cb05271157 Add note on sparse vs contiguous 2025-07-11 17:17:30 +02:00
FourteenBrush 56c221e211 Rephrasing for constants 2025-07-11 17:06:08 +02:00
FourteenBrush 8cbf75c928 Add type_enum_is_contiguous intrinsic 2025-07-11 17:03:49 +02:00
FourteenBrush 5ce8d1ede8 Add clangd stuff to gitignore 2025-07-11 16:58:47 +02:00
Jeroen van Rijn e647f560db Try fix NetBSD CI 2025-07-11 15:47:55 +02:00
Jeroen van Rijn 3b05198908 Merge pull request #5453 from Kelimion/utf-conv
Fix #5452
2025-07-11 15:35:51 +02:00
Jeroen van Rijn e89abd006f Fix #5452 2025-07-11 15:29:27 +02:00
Jeroen van Rijn d42c46dad9 Merge pull request #5448 from goldenbergdaniel/kb-text-shape
Add unix build script for kb_text_shape
2025-07-10 00:49:58 +02:00
Jeroen van Rijn e735e036b4 Fix #5447
Thanks to @FourteenBrush
2025-07-09 23:55:57 +02:00
Daniel Goldenberg 78126c5684 Add linux build script for kb_text_shape 2025-07-09 14:30:22 -04:00
Colin Davidson 2dae1d8a41 fix tabbing 2025-07-07 14:36:31 -07:00
Colin Davidson 389439ccb9 Merge branch 'master' into macharena 2025-07-07 14:34:05 -07:00
Jeroen van Rijn 090cac62f9 lb_const_string -> lb_const_value 2025-07-07 20:47:49 +02:00
Jon Lipstate fc78f6e83b x86 sse 2025-07-05 16:26:07 -07:00
Jon Lipstate 33c6a979e9 fix explicit cast 2025-07-05 14:11:29 -07:00
Jon Lipstate 019084a17f table lookup intrinsic 2025-07-05 13:55:14 -07:00
Laytan 86d576f7cc Merge pull request #5432 from FourteenBrush/master
Add `slice.suffix_length`
2025-07-04 19:02:28 +02:00
Laytan 9da667b95f Merge pull request #5433 from BradLewis/fix/bit-field-docs
Add documentation to Bit_Field_Field when parsing
2025-07-04 19:02:16 +02:00
Brad Lewis bfb70baa39 Add documentation to Bit_Field_Field when parsing 2025-07-03 21:14:34 -04:00
FourteenBrush 5811525592 Add slice.suffix_length 2025-07-03 16:51:38 +02:00
Jeroen van Rijn 1a4139b25c Remove old flag from help 2025-07-01 21:13:19 +02:00
gingerBill d2e02f0434 Merge pull request #5424 from jdennis9/master
Fix incorrect type for FONTENUMPROCW in Windows API
2025-07-01 08:34:46 +01:00
Jamie Dennis ee9b4f767b Fix incorrect type for FONTENUMPROCW 2025-07-01 15:31:22 +12:00
ed 2b1a4c82ea update readme again (typo) 2025-06-30 09:42:43 -04:00
ed a51f0262e7 update readme 2025-06-30 09:40:38 -04:00
ed 1dd7076889 remove region/endregion directives, using editor extensions for comment signatures instead. 2025-06-30 09:25:35 -04:00
ed d3a9b8b5c1 update build script to rename exe to odin_sectr to prevent global path confliects 2025-06-28 20:49:57 -04:00
Jeroen van Rijn 0f79bafed2 Merge pull request #4680 from haesbaert/args-leak
Make sure we don't leak os.args. Fixes #1633.
2025-06-27 01:27:28 +02:00
Jeroen van Rijn 2e83e22141 Merge branch 'master' into args-leak 2025-06-27 01:20:37 +02:00
Hayden Gray f72b2b1530 [source-code-locations] - added options to show, obfuscate, and hide source code locations (#5412) 2025-06-26 22:43:44 +02:00
Laytan 22a48d4d9c Merge pull request #5413 from Feoramund/make-test-state-feature
testing: Make test state changes its own feature
2025-06-26 19:11:05 +02:00
Feoramund c87655525d testing: Make test state changes its own feature
This patch takes the former debug message output of a test changing its
state and makes it its own feature, toggleable with the
`ODIN_TEST_LOG_STATE_CHANGES` configurable. The output will be at the
info level and is disabled by default.
2025-06-26 12:46:03 -04:00
Laytan Laats edf071903d sdl3/ttf: remove #by_ptr usage with opaque Font
Fixes #5278
2025-06-26 17:51:57 +02:00
Laytan 5822b00c39 Merge pull request #5411 from laytan/fix-load-type-panic
fix load type panic because front-end allows a deref of a type
2025-06-26 17:32:07 +02:00
Laytan Laats 2c308bdcfa fix load type panic because front-end allows a deref of a type
Fixes #5357
2025-06-26 17:07:06 +02:00
Jeroen van Rijn 88c208d1fb Merge pull request #5408 from slowhei/master
Fix bug where compiler treats uint enums as ints
2025-06-26 14:54:20 +02:00
Jeroen van Rijn 1fbc5641c0 Add to tests/internal
Turn repro code into a proper test, and delete superfluous files from Odin root.
2025-06-26 14:47:38 +02:00
Tohei Ichikawa 8410871cb8 Fix bug where compiler treats uint enums as ints 2025-06-24 22:58:00 -04:00
Jeroen van Rijn 62e797b9d1 Merge pull request #5406 from Airtz/addendum-5402
Fix an oversight in PR #5402
2025-06-24 17:02:20 +02:00
Jeroen van Rijn ebdf2e17f3 Remove altogether. 2025-06-24 16:37:30 +02:00
Airtz fb3bccdd3e Fix an oversight for operators with more than 2 chars 2025-06-24 16:09:42 +02:00
Jeroen van Rijn 8da5eaf4a2 Merge pull request #5405 from Kelimion/self_cleanup
Expand `self_cleanup` documentation.
2025-06-24 14:40:44 +02:00
Jeroen van Rijn 4b6e375f95 Expand self_cleanup documentation. 2025-06-24 14:34:28 +02:00
Jeroen van Rijn 36ea05fba9 Merge pull request #5404 from Kelimion/posix_stat
Disable two tests under core/sys/posix.
2025-06-24 14:16:12 +02:00
Jeroen van Rijn da3ab6a609 Disable two tests under core/sys/posix. 2025-06-24 14:04:18 +02:00
Jeroen van Rijn 19d5d377df Merge pull request #5403 from flysand7/shmget-interface
sys/linux: Unify IPC_Flags and IPC_Mode bitsets
2025-06-24 11:39:36 +02:00
Sunagatov Denis e21cde0cf7 sys/linux: Unify IPC_Flags and IPC_Mode bitsets
In #5399 it was noticed, that IPC_Mode isn't being used within SystemV
IPC procedures, even though it was designed this way, which lead to a
weird API where in order to call SystemV IPC procedures multiple
transmutes and a bitwise-OR are needed.

This unifies IPC_Mode and IPC_Flags bitsets, making it possible to call
the SystemV IPC procedures without extra casts, and rearranges the flags
in a way that hopefully makes it easier to see when they are not
colliding and should not be mixed. The explanation, explaining this
arrangement of the enum was added.

The IPC_Perm structure is modified, so that the flags can be re-used
between the calls. It's probably not as good as keeping them separate,
but should work... hopefully.

Kept the "old" style of documentation for consistency.

Signed-off-by: Sunagatov Denis <thebumboni@gmail.com>
2025-06-24 20:30:50 +11:00
Jeroen van Rijn 8d89b1a448 Merge pull request #5402 from Airtz/fix-5361
Fix #5361
2025-06-24 03:21:14 +02:00
Airtz 2259db9a53 Better error messages 2025-06-24 02:54:14 +02:00
Jeroen van Rijn 8707989e57 Merge pull request #5389 from Airtz/fix-4445
Fix #4445
2025-06-23 19:14:00 +02:00
Jeroen van Rijn 8846372053 Merge pull request #5396 from Feoramund/fix-3774
Forbid nested declaration of instrumentation procedures
2025-06-23 18:33:04 +02:00
Airtz d65b1d5e94 Better proc groups inference 2025-06-23 18:10:40 +02:00
gingerBill be3f8e3c9d Merge pull request #5397 from Feoramund/fix-4865
raylib: Refer to Odin-style enum over original C enum
2025-06-23 15:47:37 +01:00
Feoramund 92005ba1a6 raylib: Refer to Odin-style enum over original C enum
Fixes #4865
2025-06-23 09:20:09 -04:00
Feoramund 3608297e0b Forbid nested declaration of instrumentation procedures
Fixes #3774
2025-06-23 09:11:16 -04:00
Feoramund d343f54d6d Fix spurious failure to compile procedures marked @instrumentation_enter
The type `Source_Code_Location` may not be available yet, which causes
the compiler to not recognize the procedure type correctly.
2025-06-23 09:03:50 -04:00
Jeroen van Rijn 1633d9b69a Merge pull request #5391 from blob1807/master
Fix memory leak in `core:math/big.internal_rat_norm`
2025-06-22 19:43:02 +02:00
blob1807 f2490191b6 Fix memory leak in internal_rat_norm 2025-06-23 02:44:00 +10:00
Airtz 38187ef206 Merge branch 'odin-lang:master' into fix-4445 2025-06-22 17:05:32 +02:00
Jeroen van Rijn 56d9671f63 Merge pull request #5368 from Airtz/master
Fix #5331 and `check_shift` improvements
2025-06-22 16:58:21 +02:00
Airtz 277130111e sign check error message update 2025-06-22 16:51:44 +02:00
Jeroen van Rijn e451e51c1d Merge pull request #5388 from BradLewis/fix/parser-stb-image
Fix issue parsing `vendor/stb/image` with the `core:odin/parser` parser
2025-06-22 16:41:42 +02:00
Airtz 19c0f43e19 Fix #4445 2025-06-22 16:15:22 +02:00
Brad Lewis fc58158fb7 Fix issue parsing vendor/stb/image with the core:odin/parser parser 2025-06-22 09:42:33 -04:00
Jeroen van Rijn 757c243aaf Merge pull request #5387 from mifreundorfer/master
Fix invalid selector for acceleration structure
2025-06-22 14:22:32 +02:00
Michael Freundorfer 109edbcec7 Fix invalid selector for acceleration structure 2025-06-22 14:10:55 +02:00
Jeroen van Rijn 2c0899156d Merge pull request #5385 from RaphGL/posix_is_supported
added IS_SUPPORTED to core:sys/posix
2025-06-21 18:26:52 +02:00
RaphGL e374ace10d added IS_SUPPORTED to core:sys/posix 2025-06-21 12:12:13 -01:00
gingerBill 8d37f9de09 Merge pull request #5378 from laytan/fix-wasm-c-abi-raw-unions
Fix WASM C ABI for raw unions
2025-06-21 11:01:52 +01:00
Jeroen van Rijn edb1f8a76d Merge pull request #5383 from Kelimion/thread-fix
Fix early join after start.
2025-06-21 11:54:46 +02:00
Jeroen van Rijn 1903d7211e Fix early join after start. 2025-06-21 11:47:00 +02:00
Jeroen van Rijn 8dc374a6ae Merge pull request #5380 from Feoramund/fix-2410
Ensure `volatile` status for all atomic operations
2025-06-21 01:55:04 +02:00
Feoramund 5b1113acb4 Ensure volatile status for all atomic operations
Fixes #2410
2025-06-20 19:43:41 -04:00
Jeroen van Rijn 7abd86c211 Clarify --- for global variable. 2025-06-21 00:05:15 +02:00
Laytan 62c5805c91 Merge pull request #5150 from wishfoundry/patch-1
spelling in compilation errors
2025-06-20 22:37:03 +02:00
Laytan 2995557394 Merge pull request #5211 from Barinzaya/union-custom-align-tag-size
Consider custom `#align` when determining union tag size
2025-06-20 22:31:31 +02:00
Laytan 7d8f41b938 Merge pull request #5379 from Feoramund/fix-4711
Push `context` onto stack before evaluating procedure parameters
2025-06-20 22:24:08 +02:00
Laytan Laats 30e1c96269 uncomment test, see if it's fixed 2025-06-20 22:15:21 +02:00
Laytan 7f648d11d6 Merge pull request #5329 from JackMordaunt/jfm-fix_chan_try_send
chan: fix try_send and send
2025-06-20 22:11:39 +02:00
Feoramund 378e72b211 Push context onto stack before evaluating procedure parameters
Fixes #4711
2025-06-20 16:11:08 -04:00
Laytan Laats 3db8972c99 add return 2025-06-20 22:07:46 +02:00
Laytan Laats 3a86bc9c6d Fix WASM C ABI for raw unions 2025-06-20 22:04:53 +02:00
Jeroen van Rijn 8e782d9a00 Merge pull request #5376 from Creativty/master
#5270 Escape Object files properly during linker_stage
2025-06-20 21:51:48 +02:00
xenobas 0ed54d3557 fix: escape object files with single quotes during linking 2025-06-20 19:40:24 +01:00
Jeroen van Rijn f3c618f98d Merge pull request #5375 from RaphGL/tiocgwinsz_time
Added TIOCGWINSZ to darwin, linux and freebsd
2025-06-20 20:02:15 +02:00
Raph a7e89e1324 Merge branch 'master' into tiocgwinsz_time 2025-06-20 16:50:00 -01:00
RaphGL 0b5be6ad6a added TIOCGWINSZ to darwin, linux and freebsd 2025-06-20 16:45:05 -01:00
Jeroen van Rijn d9e08bc5d8 Merge pull request #5374 from Feoramund/fix-regex-docs
Fix RegEx docs
2025-06-20 16:50:07 +02:00
Feoramund b82753227d sys/posix: Correct reference to core:text/regex 2025-06-20 10:46:40 -04:00
Feoramund 09690691b6 text/regex: Remove old docmentation and unneeded flag
`Unsupported_Flag` was used back when the iterator did not handle
`.Multiline`.
2025-06-20 10:45:48 -04:00
Airtz 4dd0048922 Merge branch 'odin-lang:master' into master 2025-06-20 14:16:46 +02:00
Jeroen van Rijn 208ace0b03 Merge pull request #5372 from Feoramund/forbid-ba-invalid-pointer-print
More `Buddy_Allocator` safeguards
2025-06-20 13:09:06 +02:00
Jeroen van Rijn 6563230bd0 Add kb to vendor/README.md 2025-06-20 13:05:17 +02:00
gingerBill 565c612f4a Fix typo 2025-06-20 11:52:18 +01:00
Feoramund 4d4356e806 mem: Guard against Buddy_Allocator overwriting metadata 2025-06-20 06:44:44 -04:00
Feoramund bfa0e1110a mem: Don't print Buddy_Allocator.tail
This is always a pointer past the end of the buffer given to
`buddy_allocator_init`, which could be an invalid address. Printing may
result in a segmentation violation.
2025-06-20 06:41:42 -04:00
gingerBill 293267c7b2 Move #assert to types file 2025-06-20 10:48:30 +01:00
gingerBill 62db888ac1 Change c.int to b32 2025-06-20 10:47:26 +01:00
gingerBill 676727114f Add to ShapeDynamic to kb_text_shape_procs.odin 2025-06-20 10:30:16 +01:00
gingerBill d25cd01b42 Merge pull request #5371 from odin-lang/bill/vendor/kb-text-shape
`vendor/kb_text_shape`
2025-06-20 10:17:02 +01:00
gingerBill 4b99498e17 Merge pull request #5370 from Valakor/master
Update vendor:sdl3 from 3.2.10 to 3.2.16, and vendor:sdl3/image from 3.2.0 to 3.2.4
2025-06-20 10:12:18 +01:00
gingerBill 0a7cf8cfe1 Even more minor changes 2025-06-20 10:07:17 +01:00
gingerBill e5a4f3bcae More type corrections/improvements 2025-06-20 09:59:25 +01:00
gingerBill 41e3bda2a9 Fix enum size 2025-06-20 09:51:04 +01:00
gingerBill 37fffe78d6 Use bit_fields to describe internal break_state 2025-06-20 09:48:45 +01:00
gingerBill f055d8e714 Slight change to un definition 2025-06-20 09:42:05 +01:00
gingerBill 9d15170928 Change types where possible to the correct ones 2025-06-20 09:29:41 +01:00
gingerBill a449ad8ed8 Keep -vet happy 2025-06-20 09:20:50 +01:00
gingerBill 9a328e1c97 Use multiple return values where possible 2025-06-20 09:17:02 +01:00
gingerBill c3e9b16d5a Update types 2025-06-20 09:09:04 +01:00
gingerBill 448702875e Add vendor:kb_text_shape to examples/all/all_vendor.odin 2025-06-20 09:05:50 +01:00
gingerBill 8f115c5bc8 Remove need for CRT with kb_text_shape and implement the allocating calls manually 2025-06-20 09:03:56 +01:00
gingerBill c056fb7512 Update procs 2025-06-20 08:38:53 +01:00
gingerBill 61edcdbfc5 Add lib and build script (Windows Only) 2025-06-20 08:38:20 +01:00
gingerBill 63f1c5139a Add types and procs for kb_text_shape 2025-06-20 08:32:25 +01:00
gingerBill 365d9b0a63 Add kb_text_shape.h 2025-06-20 07:48:05 +01:00
Matthew Pohlmann 6377afbab7 - Update SDL3 from 3.2.10 to 3.2.16
- Update SDL3_image from 3.2.0 to 3.2.4
2025-06-19 20:15:09 -07:00
Airtz 7c5b5618e8 check_is_expressible instead of convert_to_typed when there is no type_hint 2025-06-20 04:49:39 +02:00
Jeroen van Rijn 6ff5971e72 Merge pull request #5369 from Feoramund/fix-3435
Fix #3435
2025-06-20 02:26:24 +02:00
Feoramund d307e44948 Add *.a to .gitignore 2025-06-19 20:03:45 -04:00
Feoramund 2c40a198fe Make check_all.sh executable, fix two typos 2025-06-19 20:03:37 -04:00
Feoramund 7022ad8378 Add test for issue #3435 2025-06-19 19:54:12 -04:00
Feoramund c2f3d074e3 mem: Forbid construction of Buddy_Allocator with insufficient space
This takes into account eventual alignment.
2025-06-19 19:41:39 -04:00
Feoramund 57e2d8f1dd mem: Fix Buddy_Allocator size calculation to truly include alignment
This didn't take into account the size of the header plus the size of
the allocation itself by virtue of `align_forward_uint`; this could
result in no change if `size` was equal to `b.alignment` because the
number is aligned, and if `actual_size` and `size` ended up being equal,
no additional space would be requested.

This meant that a block would end up being allocated on top of its
buddy's head.

Fixes #3435
2025-06-19 19:41:38 -04:00
Feoramund 4e9f15965a mem: Fix inverted condition in buddy_allocator_alloc_bytes_non_zeroed
This was causing the procedure to find a block, then find one again,
or to not find a block and not try again.
2025-06-19 19:33:51 -04:00
Airtz c7c5258c58 Update check_expr.cpp 2025-06-20 01:23:40 +02:00
Jeroen van Rijn 7d670cff0d Merge pull request #5367 from Kelimion/fix-5366
Fix #5366
2025-06-19 22:54:48 +02:00
Jeroen van Rijn 9c810e8340 Fix #5366 2025-06-19 22:46:51 +02:00
Jeroen van Rijn 69c0fe8305 Merge pull request #5344 from Feoramund/fix-2694
Review `core/mem/allocators.odin`
2025-06-19 18:35:17 +02:00
David Holland 0a45d4de0c Fix WAVEFORMATEX struct size (#5356)
* fix WAVEFORMATEX struct size
* fix size test for WAVEFORMATEX
* pack WAVEFORMATEXTENSIBLE
2025-06-18 12:25:09 +02:00
Jeroen van Rijn 12bd926f18 Merge pull request #5354 from Kelimion/init_net
Allow `core:net` to be imported with `-default-to-panic-allocator`.
2025-06-17 15:45:22 +02:00
Jeroen van Rijn a65ece4426 Allow core:net to be imported with -default-to-panic-allocator. 2025-06-17 15:36:17 +02:00
Jeroen van Rijn f3a52a632c Merge pull request #5351 from peperronii/master
Added GetThreadDescription kernel32.odin
2025-06-17 11:03:08 +02:00
PePerRoNii a0e2931dc2 Added GetThreadDescription kernal32.odin 2025-06-17 15:36:48 +07:00
Jeroen van Rijn 91b5cec8e8 Merge pull request #5349 from Kelimion/check_all
Check all
2025-06-16 23:52:39 +02:00
Jeroen van Rijn 6d01aa9069 Appease -vet for haiku 2025-06-16 23:30:22 +02:00
Jeroen van Rijn 246deda2c5 Remove unneeded ; for essence 2025-06-16 23:03:07 +02:00
Jeroen van Rijn 29d9a12491 Add check_all scripts 2025-06-16 22:26:24 +02:00
Jeroen van Rijn c4fb5ebf9b Merge pull request #5348 from Kelimion/get_env_buffer
Get env buffer
2025-06-16 20:51:06 +02:00
Jeroen van Rijn b9809e7aa4 OpenBSD 2025-06-16 20:39:19 +02:00
Jeroen van Rijn 73dcc39d98 Fix macOS 2025-06-16 20:22:15 +02:00
Jeroen van Rijn 6347c87b5b Add buffered get_env variants to os2 2025-06-16 20:12:27 +02:00
Jeroen van Rijn eef07431ef Factor out buffered utf helper. 2025-06-16 20:12:27 +02:00
Jeroen van Rijn 1a2f83f123 Add bring-your-own-buffer versions of os.lookup_env and os.get_env
And make `core:terminal` use it so that `core:log` can be imported with `-default-to-nil-allocator`,
in which the actual allocator is set up in `main()`.

Windows was tricky because of the utf-8 <> utf-16 conversion, so we use some temporary stack buffers for that purpose,
limiting the non-allocating version there to 512 utf-16 characters each for the key and environment value.

In general the value is (obviously) limited to the size of the supplied buffer, and a `.Buffer_Full` error is returned
if that buffer is insufficient. If the key is not found, the procedure returns `.Env_Var_Not_Found`.

TODO:
- Factor out buffer-backed utf8 + utf16 conversion to `core:sys/util` to more easily apply this pattern.
- Add similar `lookup_env` and `get_env` procedures to `core:os/os2`.

Fixes #5336
2025-06-16 20:12:26 +02:00
Jeroen van Rijn 03e5636abe Merge pull request #5347 from Feoramund/test-expect-assert
Let tests expect assertion failures and signals raised
2025-06-16 19:51:04 +02:00
Feoramund 36762ce081 Add tests for new test failure expectation API 2025-06-16 11:25:32 -04:00
Feoramund 71c6b0c8f0 testing: Add API to expect signals and assertion failures 2025-06-16 11:25:32 -04:00
Jeroen van Rijn 1bd48df41f Disable test_try_select_raw_happy 2025-06-16 12:59:24 +02:00
Jeroen van Rijn d79d5237ad Merge pull request #5346 from Airtz/master
Fix typo in `error_article_table` lookup
2025-06-16 12:40:03 +02:00
Airtz fe7fbfedc0 Fix typo in error_article_table lookup 2025-06-16 12:22:03 +02:00
Jeroen van Rijn 4281dc4999 Attempt fix brew errors (#5345)
Disable macOS Intel for now.
2025-06-16 12:06:20 +02:00
Jeroen van Rijn 9c9380d158 Merge pull request #5315 from peperronii/master
Expose getpeername() in core:net package as "peer_endpoint"
2025-06-16 11:30:34 +02:00
PePerRoNii acdab793d9 Added Socket_Info_Error to Network_Error union 2025-06-16 16:17:48 +07:00
Jeroen van Rijn 795ceec2cd Merge pull request #5327 from nubunto/fix/pool-join-hangs
fix: pool_join hangs if no threads are started
2025-06-16 10:50:35 +02:00
Bruno Panuto 6874a4cdb0 fix: make pool_finish not hang when pool_start is not called 2025-06-16 00:28:43 -03:00
Feoramund 7526549e51 Disable usage of AddressSanitizer (pt. 2) 2025-06-15 15:34:18 -04:00
Feoramund 5e929b596d Merge branch 'master' into fix-2694 2025-06-15 15:30:26 -04:00
Feoramund efba9a1fb7 Disable usage of AddressSanitizer pending a per-allocator review
It has been discovered that AddressSanitizer does not keep a 1:1 mapping
of which bytes are poisoned and which are not. This can cause issues for
allocations less than 8 bytes and where addresses straddle 8-byte
boundaries.

See the following link for more information:

https://github.com/google/sanitizers/wiki/AddressSanitizerAlgorithm#mapping
2025-06-15 15:06:28 -04:00
Feoramund 0b2cf9a4ca Add a tiny sanity test for core:mem allocators 2025-06-15 14:29:30 -04:00
Feoramund 134c39b58b mem: Standardize panic messages 2025-06-15 12:34:16 -04:00
Feoramund e4258b151e mem: Review all documentation comments 2025-06-15 12:34:16 -04:00
Feoramund 7524762620 mem: Poison memory for Buddy_Allocator 2025-06-15 12:34:16 -04:00
Feoramund 7e77bd425f mem: Guard against size 0 in dynamic_arena_resize_* 2025-06-15 12:34:16 -04:00
Feoramund 78a10b462f mem: Poison memory for Dynamic_Arena 2025-06-15 12:34:16 -04:00
Feoramund de3c322899 mem: Make dynamic_arena_alloc not private
None of the other `*_alloc` procs are private, and this proc is even
referenced in public documentation comments.
2025-06-15 12:34:16 -04:00
Feoramund 652c0c997d mem: Remove bogus comments
There is no `dynamic_arena_free`; the mode is not implemented
2025-06-15 12:34:15 -04:00
Feoramund c1e3171178 mem: Remove comment about calling panic
The behavior is codified in the comment as returning `Invalid_Pointer`.
2025-06-15 12:34:15 -04:00
Feoramund aaeae8bc7d mem: Remove trailing whitespace 2025-06-15 12:34:15 -04:00
Feoramund 47a54dd11a mem: Panic when passing invalid pointers to small stack free/resize
This is consistent with `Stack_Allocator`.
2025-06-15 12:34:15 -04:00
Feoramund d7e98ba82a Add test for issue #2694 2025-06-15 12:34:15 -04:00
Feoramund 3261896790 mem: Correct wrong error message 2025-06-15 12:34:15 -04:00
Feoramund aa41a77fc4 mem: Check if alignment matches on Small_Stack resize 2025-06-15 12:34:15 -04:00
Feoramund 3a02918efc mem: Make small_stack_resize* free if size is 0 2025-06-15 12:34:15 -04:00
Feoramund a4771ce1b5 mem: Clarify what happens when you free out-of-order in a Small_Stack 2025-06-15 12:34:15 -04:00
Feoramund 21a17c1ae6 mem: Replace auto_cast 2025-06-15 12:34:15 -04:00
Feoramund 8f68c46467 mem: Don't unpoison the header of a Small_Stack allocation 2025-06-15 12:34:15 -04:00
PePerRoNii c08d9c50c8 Changed TCP_Recv_Err to Socket_Info_Err and tested on darwin_arm64 2025-06-15 12:14:59 +07:00
PePerRoNii 42aa8ac383 Implemented _socket_info_error on peer_endpoint and bound_endpoint 2025-06-15 11:17:49 +07:00
PePerRoNii f49bf1abd2 added Socket_Info_Errors Enum 2025-06-15 10:26:06 +07:00
Feoramund 5798151a0e mem: Poison unused memory more thoroughly 2025-06-14 13:21:15 -04:00
Feoramund ae96b276c1 mem: Check if alignment matches on Stack_Allocator resize 2025-06-14 13:21:15 -04:00
Feoramund 837d8cf72c mem: Actually resize when resizing for Stack_Allocator
Changed the check from `bytes` to `err` for safety's sake, too.

This will prevent the potential bug of allocating non-zero memory, then
doing a zeroed resize, which will result in having garbage data in the
initial half.
2025-06-14 13:21:14 -04:00
Feoramund f701aeffd5 mem: Correct wrong error message 2025-06-14 13:21:14 -04:00
Feoramund 7580dc2dd0 mem: Remove pointless check in Scratch_Allocator
The backup allocator is set at `init` which happens even if `Scratch` is
nil at the head of `scratch_alloc_bytes_non_zeroed`.
2025-06-14 13:21:14 -04:00
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
Jeroen van Rijn 771c1c4332 Merge pull request #5334 from Kelimion/types-checks
Add additional nullptr checks in types.cpp
2025-06-14 01:22:15 +02:00
Jeroen van Rijn cc08dca53d Add additional nullptr checks in types.cpp
Ran into a bunch of nullptr problems while reviving an 8-year old Odin problem.
2025-06-14 01:13:36 +02:00
Laytan Laats 144daf6fff add macOS Tahoe to odin report and core:sys/info 2025-06-14 00:27:37 +02:00
Jack Mordaunt 17927729dd core/sync/chan: (unbuffered) ack reads
This fixes an issue where a call to close could intercept the dance
between send and recv, causing send to report incorrectly that a value
was not transmitted (when it actually was).
2025-06-13 18:08:44 -03:00
Jack Mordaunt 130b2dc36d tests/core/sync/chan: test concurrent send/close/recv
This test is designed to ensure that a call to send will always
correctly report whether the value was transmitted. If recv wins, a
close call should not be able to intercept the send thread.
2025-06-13 18:07:21 -03:00
Laytan aa0cffb412 Merge pull request #5328 from laytan/compat-allocator-improvements
mem: compat allocator improvements
2025-06-13 19:41:58 +02:00
Jeroen van Rijn f03484e352 Merge pull request #5332 from Kelimion/replace_environment_variables
Replace core:posix usage in core:os/os2
2025-06-13 18:15:31 +02: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
Jeroen van Rijn 84eaddbd47 WASI 2025-06-13 18:08:35 +02:00
Jeroen van Rijn 8c8406cc4d stub out get_env for js 2025-06-13 18:00:30 +02:00
Jeroen van Rijn 3862555153 Replace core:posix usage in core:os/os2 2025-06-13 17:49:05 +02:00
Jeroen van Rijn fe9f74f7a2 Disable PR comments 2025-06-13 07:24:03 +02:00
Jack Mordaunt 760d8c1cdd core/sync/chan.send: return false if channel is closed while blocked
This commit makes send behave the same as recv: that the call will
return false if the channel is closed while a thread is waiting on the
blocking operation.

Prior logic would have send return true even if the channel was actually
closed rather than read from.

Docs adjusted to make this clear.
Tests added to lock in this behaviour.
2025-06-12 17:35:49 -03:00
Jack Mordaunt 2d12e265cc tests/core/sync/chan: add test for contended try_send
This test ensures that contending threads racing to try_send against a
single blocking read will result in exactly one winner without any
senders blocking.
2025-06-12 17:35:48 -03:00
Jack Mordaunt c29168f76f core/sync/chan.try_send: avoid blocking if no reader is available
This changes the semantics of try_send to be consistently non-blocking.

That is, if the buffered is full OR there are no readers it returns
false.

The previous behaviour was such that it would block in the latter case
of no reader, and it would wait for a reader. That is problematic
because it produces inconsistent behaviour between buffered and
unbuffered channels which is astonishing and adds complexity to the
caller.

To illustrate the problem with the old behaviour, consider the
try_select operation: if a send-channel happens to be unbuffered the
try_select (which wants to never block) can now block, that unbuffered
send channel is selected (at random) and there is no reader on the other
side. Thus we have unpredictable blocking behaviour, which breaks the
guarantee that try_select never blocks.

If you want a blocking send you can just call "send" (the blocking
variant).

In addition, there is some reader/writer math done inside
can_{send,recv} such that they only report true if there is sufficient
reader/writer capacity. If there is contention we need to ensure that
each reader is paired to exactly one writer.

Consider try_send: if there is a single reader we can send. If there is
a single reader and a single writer, then we cannot send, as that reader
will be paired with the existing writer. Therefore can_send is only true
if there are more readers than writers at the time of check.

NOTE: The original tests don't need to use wait-looping with thread.yield()
or heuristic sleep. Instead we can just use blocking channel operations
rather than non-blocking operations.
2025-06-12 17:35:48 -03:00
Jack Mordaunt 52d38f1788 test/core/sync/chan: serialize try_select tests
These tests will race access to __global_context_for_test, which can
cause the test suite to flake. Even though only a single test actually
references the variable, the logic in try_select consumes it.
2025-06-12 17:15:37 -03:00
Laytan fc7fc4d5cd Merge pull request #5289 from JackMordaunt/jfm-sync_chan_refactor
Jfm sync chan refactor
2025-06-12 21:51:34 +02:00
Jack Mordaunt 3c3fd6e580 tests/core/sync/chan: move global state into test
While this state is not actually needed by more than one test, we can
just make it a static variable.
2025-06-12 16:14:52 -03:00
Jack Mordaunt c1cd525d9d core/sync/chan.select_raw: call try_select_raw with deprecation warning
Eventually select_raw should be a blocking select operation, but for now
we need to migrate people away.
2025-06-12 16:14:52 -03:00
Jack Mordaunt 96b91849a9 core/sync/chan.try_select_raw: fix doc comment typo
Signed-off-by: Jack Mordaunt <jackmordaunt.dev@gmail.com>
2025-06-12 16:14:52 -03:00
Jack Mordaunt 4d7c182f7d tests/core/sync/chan: test harness for chan.try_select_raw
This test harness ensures consistent non-blocking semantics and
validates that we have solved the toctou condition.

The __global_context_for_test is a bit of a hack to fuse together the
test supplied proc and the executing logic in packaage chan.
2025-06-12 16:14:52 -03:00
Jack Mordaunt faae81ba61 core/sync/chan.try_select_raw: test hook for testing the toctou
This is necessary because we need to allow the test guarantee against a
rare condition: where a third-party thread steals a value between the
validity checks can_{send,recv} and the channel operation
try_{send,recv}.
2025-06-12 16:14:52 -03:00
Jack Mordaunt 4043be8567 core/sync/chan.try_select_raw: skip nil input messages
This makes the proc easier and safer to call by letting the caller nil
out messages to skip sends.
2025-06-12 16:14:52 -03:00
Jack Mordaunt fb39e5a2f8 core/sync/chan.try_select_raw: clarify loop control flow
Use a label to clarify the continue statements.
2025-06-12 16:14:52 -03:00
Jack Mordaunt d5b7302ac0 core/sync.try_select_raw: fix TOCTOU
Fixes a TOCTOU where the channel could be used between the call to
can_{recv,send} and {recv,send} causing an unexpected blocking
operation.

To do this we use the non-blocking try_{recv,send} and retry the check
in a loop. This guarantees non-blocking select behaviour, at the cost of
spinning if the input channels are highly contended.

Signed-off-by: Jack Mordaunt <jackmordaunt.dev@gmail.com>
2025-06-12 16:14:52 -03:00
Jack Mordaunt be873af003 core/sync.select_raw: rename to try_select_raw
This follows the convention where non-blocking operations are prefixed
with "try" to indicate as much.

Since select_raw in it's current form doesn't block, it should be
try_select_raw, and allow select_raw to name a blocking implementation.
2025-06-12 16:14:52 -03:00
Jack Mordaunt 7f9589922d core/sync.select_raw: return a useful index
This fixes a flaw in the original implementation: the returned index is
actually useless to the caller.

This is because the index returned refers to the internal "candidate"
list. This list is dynamic, and may not have all of the input channels
(if they weren't ready according to chan.can_{recv,send}). That means
the index is not guaranteed to mean anything to the caller.

The fix introduced here is to return the index into the input slice
(recvs,sends) and an enum to specify which input slice that is.

If no selection was made, then (-1, .None) is returned to communicate as
much.

Signed-off-by: Jack Mordaunt <jackmordaunt.dev@gmail.com>
2025-06-12 16:14:51 -03:00
Laytan Laats 67a8b035db mem: compat allocator improvements
1. store alignment instead of original pointer
2. implement .Query_Info
3. poison the header and alignment portion of the allocation
4. .Resize uses `max(orig_alignment, new_alignment)` as it's alignment
   now
5. .Free passes along the original alignment
2025-06-12 20:40:22 +02:00
Laytan Laats 0ed6cdc98e mem/tlsf: fix asan reporting poisoning of already poisoned region
free on tlsf poisons the entire block, while alloc might only unpoison a
part of it (cause it's size is aligned up). This causes free to
potentially poison an already poisoned portion, which is a
use-after-poison.

Because this is "fine" and intended, I opted to just
@no_sanitize_address it.
2025-06-12 19:37:24 +02:00
Jeroen van Rijn 74f70bfbcb Comment 2025-06-12 17:09:33 +02:00
Jeroen van Rijn 298bab99a4 Merge pull request #5326 from Kelimion/fix-5321
Revert changes to thread_unix.odin
2025-06-12 16:56:29 +02:00
Jeroen van Rijn 5aa377e64e Revert changes to thread_unix.odin 2025-06-12 16:36:40 +02:00
Jeroen van Rijn b119ca0261 Merge pull request #5325 from Kelimion/fix-5321
Fix #5321
2025-06-12 16:14:01 +02:00
Jeroen van Rijn 59ba37f232 Remove transmute 2025-06-12 16:05:34 +02:00
Jeroen van Rijn 994b5a2a6c Remove c import 2025-06-12 16:01:31 +02:00
Jeroen van Rijn caf41aa046 Fix #5321 2025-06-12 16:00:24 +02:00
Jeroen van Rijn eb1b5f7d3a Merge pull request #5322 from Kelimion/fix-5321
Fix #5321 (on Windows)
2025-06-12 11:52:38 +02:00
Jeroen van Rijn ac5f3746cf Fix #5321 2025-06-12 11:30:36 +02:00
Jeroen van Rijn 50ff3fabdc Merge pull request #5317 from Feoramund/fixup-container-queue
Tidy up `core:container/queue`
2025-06-12 00:00:34 +02:00
Jeroen van Rijn a2be547dfd Merge exclude paths 2025-06-11 21:00:38 +02:00
Jeroen van Rijn 8a08edbdc7 Merge pull request #5319 from Kelimion/coverage
Add code coverage
2025-06-11 20:39:48 +02:00
Jeroen van Rijn 828d4c71d2 Now? 2025-06-11 20:33:12 +02:00
Jeroen van Rijn 921414aa74 Let's use the latest Ubuntu and a recent LLVM 2025-06-11 20:04:07 +02:00
Jeroen van Rijn 3965b2e4b4 kcov --version 2025-06-11 19:58:01 +02:00
Jeroen van Rijn 05cba0aca5 Change kcov url 2025-06-11 19:53:49 +02:00
Jeroen van Rijn d37a93cd7d Add code coverage 2025-06-11 19:43:42 +02:00
Jeroen van Rijn 7bfd70a828 Add code coverage check
Inspired by PR #4928
2025-06-11 19:34:24 +02: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
gingerBill 4aec582a05 Add system:dl to foreign import for dlfcn.odin 2025-06-11 15:27:00 +01:00
PePerRoNii a32ee6af97 added linux implementation NOTE: tcp_recv_error doesn't cover all cases 2025-06-11 13:10:37 +07:00
PePerRoNii 297fdd4075 added freebsd implementation NOTE: bsd's tcp_recv_error does not cover all cases 2025-06-11 13:05:16 +07:00
PePerRoNii 7ba4427d52 added windows implementation 2025-06-11 12:57:22 +07:00
PePerRoNii 5e11af9676 added darwin implementation 2025-06-11 12:50:20 +07:00
PePerRoNii c402ac8606 Add entry point in core:net as peer_endpoint 2025-06-11 12:44:17 +07:00
Jeroen van Rijn 5bf180d8f9 Merge pull request #5311 from Kelimion/big-tests
Turn `core:math/bìg` tests into regular `core:testing` tests.
2025-06-11 00:56:21 +02:00
Jeroen van Rijn 0f90a610a2 Delete duplicate test vectors. 2025-06-11 00:49:51 +02:00
Jeroen van Rijn 9dafd77bc0 Turn core:math/bìg tests into regular core:testing tests.
`core:math/big` has been verified against Python's big integer implementation long enough.
Turn it into a regular regression test using the `core:testing` framework, testing against
a generated corpus of test vectors.
2025-06-11 00:40:52 +02:00
gingerBill 2a292b588a Merge pull request #5305 from Feoramund/fix-4362
Guard against invalid proc types in parameter list
2025-06-10 17:15:13 +01:00
Jeroen van Rijn ca65444007 Merge pull request #5310 from Kelimion/big-rat-tests
Add initial tests for big rationals
2025-06-10 17:16:19 +02:00
Jeroen van Rijn 4e50b9d331 Fix path 2025-06-10 16:55:03 +02:00
Jeroen van Rijn 4f4839ecc5 Add initial tests for big rationals 2025-06-10 16:46:12 +02:00
Jeroen van Rijn 14d2541529 Merge pull request #5309 from Feoramund/fix-4660
Let `-no-entry-point` work for Windows DLLs
2025-06-10 15:22:45 +02:00
Feoramund 1fc390146f Let -no-entry-point work for Windows DLLs
Fixes #4660
2025-06-10 08:54:28 -04:00
Jeroen van Rijn 611390ba27 Merge pull request #5308 from Feoramund/fix-4565
Move negation in `internal_rat_to_float` to end of procedure
2025-06-10 14:43:41 +02: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
Jeroen van Rijn d1fc731a3a Merge pull request #5306 from Kelimion/fix-3449
Define empty `gb_no_asan` if VS < 2022
2025-06-10 13:27:00 +02:00
Jeroen van Rijn 6cb2408d70 Define empty gb_no_asan if VS < 2022 2025-06-10 13:20:01 +02:00
Feoramund 5ed2735658 Guard against invalid proc types in parameter list
Fixes #4362
2025-06-10 06:13:14 -04:00
Jeroen van Rijn d08e14fc3c Merge pull request #5304 from Feoramund/clarify-flags-variadic
Clarify `core:flags` variadic behaviors
2025-06-09 19:08:53 +02:00
Feoramund 6dee422700 flags: Rename varg to overflow, let it be renamed with config 2025-06-09 13:02:05 -04:00
gingerBill 002b50360c Merge branch 'master' of https://github.com/odin-lang/Odin 2025-06-09 17:19:58 +01:00
gingerBill 2ffd6be20a Fix minor typo from ^[^] to [^]^ 2025-06-09 17:19:29 +01: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
Jeroen van Rijn 4a675395c5 Merge pull request #5303 from Kelimion/fix-4705
Fix #4705
2025-06-09 15:16:46 +02:00
Jeroen van Rijn 179e5b8835 Fix #4705
Allocate `doc.tokenizer`, and free it in `destroy`.
2025-06-09 15:09:04 +02:00
gingerBill 87247b8bb7 Merge pull request #5286 from Feoramund/no-san-mem
Add `@(no_sanitize_memory)` with additions to `base:sanitizer`
2025-06-09 12:46:22 +01:00
Jeroen van Rijn b8ac777649 Merge pull request #5301 from colrdavidson/more_tzone_bugs
Fix GMT+/- timezone handling
2025-06-09 02:11:21 +02:00
Colin Davidson 3407bd7cf9 better handle offset-0 case 2025-06-08 17:03:43 -07:00
Colin Davidson 04481e0fd2 Merge branch 'master' into macharena 2025-06-08 16:17:32 -07:00
Colin Davidson b1ed22d84f fix frequency grab 2025-06-08 16:16:34 -07:00
Jeroen van Rijn 7813e9fb37 Merge pull request #5300 from Feoramund/fix-5299
Guard against untyped `nil` in type cycle and type info sections
2025-06-09 00:00:24 +02: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
Jeroen van Rijn d2d187eaaa Work around untyped nil 2025-06-08 22:53:52 +02:00
Jeroen van Rijn 0be7fe4b82 Merge pull request #5298 from slowhei/master
Added missing parameter to `gettimeofday`
2025-06-08 22:37:07 +02:00
Tohei Ichikawa 7662e7d843 Removed obsolete tz param from gettimeofday 2025-06-08 16:07:11 -04:00
Tohei Ichikawa 876f1c02b7 Added missing parameter to gettimeofday 2025-06-08 12:47:50 -04:00
Jeroen van Rijn 77f4199af6 Simplify _xdg_user_dirs_lookup 2025-06-08 14:56:41 +02:00
Jeroen van Rijn 00b67831d1 Merge pull request #5297 from karl-zylinski/dxc-binding-fixes
DXC: Fixed broken bindings of ICompiler and ICompiler2
2025-06-08 00:18:11 +02:00
Karl Zylinski 4a6c6cd398 Fixed broken bindings of ICompiler and ICompiler2. See https://learn.microsoft.com/en-us/windows/win32/api/dxcapi/ns-dxcapi-idxccompiler and https://learn.microsoft.com/en-us/windows/win32/api/dxcapi/ns-dxcapi-idxccompiler2 for correct signatures. 2025-06-08 00:11:31 +02:00
ed a2ddbb3141 Merge tag 'dev-2025-06' 2025-06-07 11:48:16 -04:00
Jeroen van Rijn 6d7f5baaf8 Merge pull request #5295 from elyalon/dirs
Fix user dirs, add docs
2025-06-07 11:13:40 +02:00
Ely Alon deeb9e2d12 remove fmt import 2025-06-07 01:40:43 +03:00
Ely Alon 17746db555 Fix user dirs, add docs 2025-06-07 01:22:30 +03:00
Jeroen van Rijn 23315195c4 Merge pull request #5294 from iarkn/type-is-bit-field
Add `intrinsics.type_is_bit_field` proc
2025-06-06 16:14:25 +02:00
iarkn 3152be01b9 Add intrinsics.type_is_bit_field proc 2025-06-06 16:01:13 +02:00
Jeroen van Rijn e7ae193c12 Merge pull request #5293 from Feoramund/nulpo-check-5215
Add `nullptr` check in `add_type_info_type_internal`
2025-06-06 15:58:03 +02:00
Feoramund 1cd1f9fec4 Add nullptr check in add_type_info_type_internal
Fixes #5215
2025-06-06 09:23:06 -04:00
Jeroen van Rijn f1ce9f98d8 Re-add htonl and htons for those porting from C. 2025-06-06 13:13:34 +02:00
Jeroen van Rijn 8389dfd050 Merge pull request #5291 from Kelimion/deprecate
Deprecate old @(deprecated) things.
2025-06-06 10:50:59 +02:00
Jeroen van Rijn 4b36306674 Deprecate old @(deprecated) things. 2025-06-06 10:42:34 +02:00
Jeroen van Rijn e870369c97 Merge pull request #5288 from Feoramund/strconv-append-to-write
Clarify `strconv.append_*` to `strconv.write_*`
2025-06-05 23:45:37 +02: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
Jeroen van Rijn 108c8781c7 Factor out into helper. 2025-06-05 22:27:18 +02: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
Jeroen van Rijn 90a1b0ec4b UAF 2025-06-05 21:45:36 +02:00
Jeroen van Rijn 2428fa37a9 tabs 2025-06-05 21:38:59 +02:00
Jeroen van Rijn 5ce6eae366 Merge pull request #5285 from elyalon/dirs
Add more user platform dirs
2025-06-05 21:09:27 +02:00
Ely Alon a9cdb4f446 add more user dirs 2025-06-05 21:50:59 +03:00
Jeroen van Rijn 97fd228f01 Merge pull request #5284 from A1029384756/master
[parser.cpp] - packages with `.odin` in the name no longer attempt to parse as odin files
2025-06-05 17:42:00 +02:00
Hayden Gray ccdd14394e [parser.cpp] - packages with .odin in the name no longer attempt
to parse as odin files
2025-06-05 11:24:50 -04:00
Jeroen van Rijn a1759aa2fa Fix 2025-06-05 16:54:39 +02:00
Jeroen van Rijn 3412b13216 Merge pull request #5283 from Kelimion/user-dirs
Change `os2.user_*` on Windows to use `SHGetKnownFolderPath`.
2025-06-05 16:44:05 +02:00
Jeroen van Rijn 93e1c6593e Change os2.user_* on Windows to use SHGetKnownFolderPath.
Known folders can be redirected using `SHSetKnownFolderPath`, and it's a bit iffy to rely on environment variables.

This also more easily allows us to add `user_*_dir` procedures for the remaining 139 GUIDs in `known_folders.odin`, provided they have equivalents on other platforms.
2025-06-05 16:37:41 +02:00
Jeroen van Rijn da3b3a4139 Allocate return value on provided allocator 2025-06-05 15:16:35 +02:00
Jeroen van Rijn 8cd5d01dad Merge pull request #5282 from Feoramund/fix-4364
Let compound literal array be broadcast to a struct field of arrays
2025-06-05 14:02:56 +02: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
Laytan Laats 9eefa2006e encoding/cbor: support simd vectors 2025-06-04 22:00:02 +02:00
Laytan Laats 85224b21e6 encoding/cbor: support the matrix type 2025-06-04 21:51:12 +02:00
Jeroen van Rijn 1a35c7f954 Merge pull request #5279 from Feoramund/fix-4673
Be strict with type switch case column alignment too
2025-06-04 20:24:44 +02:00
Jeroen van Rijn 4838f6b542 Merge pull request #5280 from Feoramund/fix-4642
Print timings to stderr instead of stdout
2025-06-04 20:23:41 +02:00
Jeroen van Rijn bd13bdc391 Merge pull request #5281 from Feoramund/fix-4595
Guard against negative `index` in `inject_at`
2025-06-04 20:18:02 +02: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
gingerBill 6804f4c471 Add support for #soa[N]T compound literals 2025-06-04 13:56:46 +01:00
Jeroen van Rijn 77594a0dc9 Merge pull request #5268 from Kelimion/check-js
Allow `odin check examples/all` for js_wasm
2025-06-04 12:22:40 +02:00
Jeroen van Rijn 17319efd8f Remove SDL3/TTF flag NORMAL
It's a `bit_set`, and NORMAL is an empty one.

https://wiki.libsdl.org/SDL3_ttf/TTF_SetFontStyle

Fixes #5275
2025-06-04 11:22:59 +02:00
Jeroen van Rijn 1dffc2efd8 Switch to @(require) 2025-06-04 11:14:01 +02:00
Jeroen van Rijn ae5c92ac38 Enable odin check examples/all for JS. 2025-06-04 11:08:25 +02:00
Jeroen van Rijn d3922ebc06 Merge pull request #5276 from Feoramund/fix-4354
Forbid multiple uses of `-sanitize`
2025-06-04 10:48:48 +02:00
Jeroen van Rijn 986cfbcaf4 Merge pull request #5277 from benjryan/master
Add windows bindings to support overlapped IO
2025-06-04 10:41:46 +02:00
Laytan a7cbf4f7dd Merge pull request #5274 from Feoramund/fix-render-typo
Fix typo
2025-06-04 06:18:18 +02:00
Ben Ryan cd417b0d1f Add windows bindings to support overlapped IO 2025-06-04 11:34:31 +10: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
gingerBill 8923e28b2a Merge pull request #5267 from Feoramund/rewrite-atomic-rw-mutex
Rewrite `Atomic_RW_Mutex`
2025-06-03 15:32:36 +01:00
Jeroen van Rijn dd27049e13 Merge pull request #5261 from spiel0meister/master
add a missing nullptr check
2025-06-03 15:39:09 +02:00
Jeroen van Rijn fab7715c35 Allow -dynamic-literals for [dynamic]T 2025-06-03 15:22:20 +02: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
Jeroen van Rijn fcf0d4efa1 Merge pull request #5264 from LeandroLibanio28H/5243-fix-scope-attribute-proc-grouping
Fix scope attribute proc grouping (#5243 )
2025-06-03 14:49:40 +02:00
spiel0meister d1fcec63cc early return; fix indentation 2025-06-03 14:46:44 +02:00
Leandro Libanio 0f5e30783c Update check_expr.cpp
Removing iostream
2025-06-03 08:55:38 -03:00
Jeroen van Rijn 8f2a1cafd3 Merge pull request #5266 from Kelimion/fix-5265
Fix #5265
2025-06-03 11:36:24 +02:00
Jeroen van Rijn 82dfb43663 Fix #5265 2025-06-03 11:18:11 +02:00
LeandroLibanio28H e6b086e78d Removing unreacheable block (since e86fde3) 2025-06-02 20:48:25 -03:00
LeandroLibanio28H 7b612a3a15 Checking if entity is exported before checking if it's a procedure group 2025-06-02 20:14:19 -03:00
spiel0meister 648fa9e54a check if expr is null 2025-06-02 23:24:46 +02:00
Jeroen van Rijn ccef390c0c Merge pull request #4339 from laytan/fix-swizzle-in-for
fix swizzle in for in statement
2025-06-02 21:20:11 +02:00
Laytan 9f773f08f8 Merge pull request #5260 from laytan/examples-all-sdl3-and-wgpu-glue
add examples/all/sdl3 for all sdl3 dependant packages
2025-06-02 21:14:59 +02:00
Laytan Laats e09f226126 add examples/all/sdl3 for all sdl3 dependant packages
+ adds the wgpu glue packages to examples/all
2025-06-02 21:05:38 +02:00
Laytan Laats f94fc992d7 fix swizzle in for in statement
Fixes #1730
2025-06-02 20:30:48 +02:00
Laytan 8135dda2fc Merge pull request #5258 from laytan/fix-docs-writer
fix package docs in a "hacky" way
2025-06-02 17:09:59 +02:00
Laytan Laats 912018b427 fix package docs in a "hacky" way 2025-06-02 17:03:02 +02:00
Jeroen van Rijn d4a1670b93 Fix core:log on -target:js_wasm32 2025-06-02 14:44:26 +02:00
Jeroen van Rijn 2788cfaa0d Merge pull request #5255 from Feoramund/build-mode-test-all-packages
Let `-test-all-packages` work with `-build-mode:test`
2025-06-02 14:35:24 +02:00
Jeroen van Rijn e0c9bcbb80 Merge pull request #5256 from Bambo-Borris/correct-spelling-in-odin-doc-help-output
Correct spelling in `odin doc -help` output
2025-06-02 13:56:21 +02:00
Bambo-Borris 9ba68f2024 Correct spelling in odin doc -help output 2025-06-02 12:48:45 +01:00
Feoramund 16b8da6a79 Let -test-all-packages work with -build-mode:test
Fixes #3930
2025-06-02 07:47:19 -04:00
gingerBill cd1f66e85c Merge pull request #5246 from RichardFevrier/master
Posix: Signal: add SIGWINCH support
2025-06-02 11:50:49 +01:00
Jeroen van Rijn 1ea166fb97 Merge pull request #5251 from Feoramund/fix-quat-real-real-real-real
Fix a couple `quaternion` bugs
2025-06-01 20:52:46 +02: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
Jeroen van Rijn 805f7ce973 Typo fix 2025-06-01 19:22:51 +02:00
Jeroen van Rijn 405bf7cd55 Also clean up .dSym on Darwin 2025-06-01 15:59:38 +02:00
Jeroen van Rijn 349a34cb1a Also delete .pdb unless -keep-executable is supplied 2025-06-01 13:37:26 +02:00
Jeroen van Rijn 074708ddc4 Merge pull request #5250 from mstura/master
Add missing return cast in 'memory_prefix_length' on amd64 avx2
2025-06-01 12:20:19 +02:00
Matteo 56e0da4f14 Add missing return cast in 'memory_prefix_length' on amd64 avx2 2025-06-01 10:53:28 +02:00
Jeroen van Rijn c80f3db3a6 Merge pull request #5249 from Kelimion/simd_prefix
Vectorize `strings.prefix_length`.
2025-05-31 20:42:15 +02:00
Jeroen van Rijn c705756389 Fix doctest 2025-05-31 20:35:25 +02:00
Jeroen van Rijn a0f0e9e778 -vet 2025-05-31 20:30:02 +02:00
Jeroen van Rijn 890e923051 Vectorize strings.prefix_length.
Also add `strings.common_prefix`.
2025-05-31 20:24:21 +02:00
Jeroen van Rijn aedbb0bdb3 Merge pull request #5247 from Feoramund/fix-2083
Add suggestions for `quaternionN` or `complexN` conversions
2025-05-31 14:05:17 +02: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
gingerBill d52aa3f2c2 Merge pull request #5245 from TheTophatDemon/fix-odin-js-loadcstring
Fix odin.js loadCstring to use pointer address correctly.
2025-05-31 09:10:52 +01:00
gingerBill 53a8fac6ad Merge pull request #5241 from Feoramund/fix-obj-output
Fix output of object names
2025-05-31 09:10:12 +01:00
Richard Février f27f9bcd33 Posix: Signal: add SIGWINCH support 2025-05-31 10:01:59 +02:00
Alexander Lunsford edba218a7c Simplified function call to loadCstringDirect 2025-05-30 20:02:08 -05:00
Alexander Lunsford 9d223e178b Fix odin.js loadCstring to use pointer address correctly. 2025-05-30 19:50:34 -05: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
Jeroen van Rijn 843648c817 Merge pull request #5236 from Feoramund/fix-2077
Error on unterminated multi-line comment
2025-05-30 00:37:36 +02:00
Feoramund 3c1201fb2c Error on unterminated multi-line comment 2025-05-29 18:28:54 -04:00
Jeroen van Rijn 3142aaf497 Merge pull request #4063 from Feoramund/simd-memory
Vectorize `base:runtime.memory_*`
2025-05-29 23:32:19 +02: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
Jeroen van Rijn 0d0f311df1 Always provide /PDB option to linker if generating debug info.
radlink by default places the .PDB file in the working directory, even if /OUT says to place it elsewhere,
unlike link.exe, which places it next to the executable by default.

So, if compiling using -debug, we generate a PDB path even if -pdb-name wasn't used to override it.
2025-05-29 19:02:46 +02:00
gingerBill 7853a1db1c Fix #5228 2025-05-29 16:35:28 +01:00
gingerBill 74bab6d42f Fix #5232 by adding an edge case 2025-05-29 16:29:52 +01:00
gingerBill 1627a4015f Merge pull request #5231 from GloriousPtr/raddebugger-fixes
raddebugger: change table to columns
2025-05-29 12:23:02 +01:00
Mohit Sethi d2b69577bc raddebugger: change table to columns 2025-05-28 22:08:14 +01:00
gingerBill 7e564c3a35 Merge pull request #5130 from odin-lang/bill/raddebugger-custom-section
RAD Debugger support through the custom `.raddbg` section
2025-05-28 11:16:34 +01:00
Jeroen van Rijn 8597966a9f Fix rand.int_max comment 2025-05-28 11:50:24 +02:00
gingerBill ef6156aea5 Merge pull request #5229 from zclark/foundation-cmd-sel
Add missing SEL _cmd argument to objc class_addMethod IMPs
2025-05-28 09:08:22 +01:00
Zach Clark 78d83288a0 Add missing SEL _cmd argument to objc class_addMethod IMPs
When trying to grab the window pointer off the notification in a
windowDidBecomeKey implementation, I kept getting segfaults calling
notification->object(). The second argument of these needs to be a SEL.

https://developer.apple.com/documentation/objectivec/class_addmethod(_:_:_:_:)?language=objc#Discussion

I imagine existing code is getting by by setting the window information
in the delegate's context userdata, which works fine when you only have
one window as you can avoid needing to call notification->object(),
until you want one delegate assigned to two windows, hard to work around.
2025-05-27 17:04:19 -07:00
Jeroen van Rijn 2f2561a745 Merge pull request #5226 from weskerfoot/fix-csv-docs
Fix incorrect CSV reader settings for example, fix typo in docs
2025-05-27 22:52:29 +02:00
Feoramund b5bc0fdcda Remove commented block of code 2025-05-27 15:25:30 -04:00
Wesley Kerfoot cac18b4aba Fix incorrect CSV reader settings for example, fix typo in docs 2025-05-27 14:27:22 -04:00
Jeroen van Rijn db5c45602d Remove outdated optimization attributes. 2025-05-27 17:57:06 +02:00
Jeroen van Rijn f0061a77c0 Merge pull request #5224 from Kelimion/ptr_sub
ptr_sub prose clarification
2025-05-27 04:42:33 +02:00
Jeroen van Rijn 0d55764aa7 int 2025-05-27 04:42:12 +02:00
Jeroen van Rijn c513f035ad Fix example 2025-05-27 04:33:22 +02:00
Jeroen van Rijn 624c176ef3 ptr_sub prose clarification 2025-05-27 04:28:56 +02:00
Jeroen van Rijn d6ec081723 Merge pull request #5223 from Badaxis/GameInput
GameInput fixes and tweaks
2025-05-26 23:00:24 +02:00
Jeroen van Rijn 34edcf49ab Merge pull request #5222 from Badaxis/badaxis/Windows-Audio&Winmm
MAKEFOURCC: changed BYTE to byte
2025-05-26 22:56:00 +02:00
Vincent Billet 980b0499af Reordered like header, multipointers, fixes 2025-05-26 22:44:09 +02:00
Vincent Billet d98253564b MAKEFOURCC: changed BYTE to byte 2025-05-26 22:31:21 +02:00
Jeroen van Rijn 4d3593afc9 Update rlgl.LoadFramebuffer signature to match raylib 5.5 change 2025-05-26 21:50:13 +02:00
Jeroen van Rijn cb9d2d00e3 Merge pull request #5221 from Badaxis/badaxis/XAudio2
Create() rework; comments tweaks; +hrtfapoapi
2025-05-26 21:39:39 +02:00
Vincent Billet 15d8e43628 "do" removed 2025-05-26 21:30:32 +02:00
Jeroen van Rijn d156c2663a Merge pull request #5220 from Feoramund/fix-multiline-regex
Fix multiline RegEx iteration (breaking change for `.Multiline` usage)
2025-05-26 21:24:02 +02:00
Vincent Billet b775b4a1f1 Create() rework; comments tweaks; +hrtfapoapi 2025-05-26 21:17:44 +02:00
Jeroen van Rijn ee132b39d4 Clarify optimization mode affecting use-separate-modules 2025-05-26 20:50:43 +02: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
Laytan Laats eac58fc640 sys/info: populate cpu.physical_cores and cpu.logical_cores on Darwin 2025-05-26 20:41:18 +02:00
Jeroen van Rijn 0f0d69ea4c Clarify Darwin minimum OS version 2025-05-26 20:38:04 +02:00
Jeroen van Rijn 725cc53c65 Typo 2025-05-26 20:29:49 +02:00
gingerBill 4f7ed35435 Merge pull request #5192 from Badaxis/badaxis/Windows-Audio&Winmm
COM & Audio bindings
2025-05-26 19:20:27 +01:00
Laytan f1da10469e Merge pull request #5212 from sven-strothoff/glfw-bool-returns
Use b32 for GLFW functions that return GLFW_TRUE or GLFW_FALSE
2025-05-26 20:19:46 +02:00
gingerBill 36a8e81e4d Merge pull request #5219 from laytan/wgpu-25.0.2.1
wgpu: update to 25.0.2.1
2025-05-26 19:18:59 +01:00
Laytan Laats 88908d7f78 wgpu: update to 25.0.2.1 2025-05-26 20:06:11 +02:00
Laytan Laats 478c923e2c fix another type alias issue with mini cycle 2025-05-26 19:48:28 +02:00
Jeroen van Rijn 229c734820 Add comments to builtin.odin, documenting ODIN_* constants. (#5218)
And document constants not previously listed.
2025-05-26 18:58:59 +02:00
Vincent Billet 9b7bb9290e HRESULT_FROM_WIN32 correction 2025-05-26 08:52:46 +02:00
Vincent Billet bb274ab512 Merge branch 'odin-lang:master' into badaxis/Windows-Audio&Winmm 2025-05-26 08:16:45 +02:00
Jeroen van Rijn 655fab7227 Add core/hyperthread count for Windows and Linux (#5216)
Add core/hyperthread count to `core:sys/info` for Windows and Linux.
TODO: Linux RISCV, Linux ARM, Darwin, and the BSDs.
2025-05-25 19:43:10 +02:00
ed 2138e308d8 Merge remote-tracking branch 'offical/bill/raddebugger-custom-section' 2025-05-25 09:25:29 -04:00
Sven Strothoff 7c69cb399a Use b32 for GLFW functions that return GLFW_TRUE or GLFW_FALSE 2025-05-25 00:37:26 +02:00
Barinzaya 717b9f1578 Change union tag size to account for #align.
The prior behavior was adjusting the tag size based on the alignment of
the types in the union, even when the union has a custom alignment
specified with `#align`. This changes the behavior so that a custom
alignment, if specified, takes precedence over the alignment of the
types.
2025-05-24 12:41:28 -04:00
Jeroen van Rijn 0a6dced9da Merge pull request #5210 from Barinzaya/core-math-big-range-check
Fix range check in `core:math/big`'s `int_atoi`
2025-05-24 17:43:00 +02:00
Barinzaya d402b7408d Fix a range check in int_atoi in core:math/big.
The check seems to have been assuming that rune comparisons are
unsigned, but they're signed. This was causing an assertion failure for
certain input characters (anything with an ASCII value less than
'+'/43).
2025-05-24 11:31:37 -04:00
Jeroen van Rijn 142dd58b27 Merge pull request #5209 from Feoramund/regex-fixes
Fix RegEx iterator, remove `.Global`, make patterns unanchored by default (breaking change)
2025-05-24 15:38:26 +02:00
gingerBill 7b0b5d9adf Merge branch 'master' of https://github.com/odin-lang/Odin 2025-05-24 14:18:22 +01:00
gingerBill 594f1b30b4 Add Suggestion: 'context = runtime.default_context()' 2025-05-24 14:18:16 +01: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
Jeroen van Rijn 8b657379f3 Typo fix 2025-05-23 17:07:08 +02:00
Jeroen van Rijn 3d60b219c1 Allow text/scanner to scan 0h hex floats 2025-05-23 14:02:49 +02:00
Jeroen van Rijn 7ad8f21e79 Merge pull request #5205 from HeHHeyboi/signature-fix
Correct RWwrite signature in vendor:sdl2
2025-05-23 11:35:38 +02:00
HeHHeyboi 020dd57b06 Correct RWwrite signature 2025-05-23 15:29:08 +07:00
Jeroen van Rijn 84b140f963 Rename -keep-test-executable to -keep-executable 2025-05-23 08:47:48 +02:00
Jeroen van Rijn f716d4c88f your your 2025-05-23 08:32:16 +02:00
Jeroen van Rijn 12167bace0 Tweak #5202
Back out the new `-build-only` for tests in favor of the more established `-build-mode:test`, but retain the new `-keep-test-executable` option and default cleanup of test executables.
2025-05-23 08:28:27 +02:00
Laytan 1886c7df0a Merge pull request #5203 from mothfuzz/patch-3
Correct mipmapFilter field name in wgpu.js
2025-05-23 07:48:52 +02:00
Jeroen van Rijn 149c563146 Merge pull request #5204 from Feoramund/freebsd-sanitizer
Enable all sanitizers on FreeBSD
2025-05-23 07:19:30 +02:00
Feoramund 6c5b96948e Enable all sanitizers on FreeBSD 2025-05-22 21:39:35 -04:00
Gaia 433a21b6ff Update wgpu.js
mipmapFilter is being ignored and defaulting to .Nearest on web platforms due to incorrect capitalization of the field name
2025-05-22 19:46:31 -05:00
Jeroen van Rijn 82c9681e28 Merge pull request #5202 from Feoramund/fix-2035
Add `-build-only`, `-keep-test-executable`, delete test executable after running
2025-05-23 00:13:36 +02: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
gingerBill c383e550f9 Merge branch 'master' into bill/raddebugger-custom-section 2025-05-22 16:04:42 +01:00
gingerBill 93d2e6aca2 Merge pull request #5200 from rope-hmg/master
Added Semaphore API to the SDL3 vendor bindings
2025-05-22 15:59:32 +01:00
Hector affced2d02 Added Semaphore API to the SDL3 vendor bindings 2025-05-22 15:35:09 +01:00
gingerBill 34e998c1fc Merge pull request #5173 from Feoramund/fix-linux-shared-lib-runtime-call
Keep shared libraries from calling main program's startup/cleanup procs on Linux
2025-05-22 15:27:53 +01:00
Feoramund 713360a792 Keep shared libraries from calling main program's startup/cleanup procs on Linux 2025-05-22 09:40:37 -04:00
Jeroen van Rijn 9421b77eb5 Merge pull request #5198 from Feoramund/fix-2807
Only trim `.odin` from build filenames
2025-05-22 15:01:35 +02:00
Feoramund e35e1dcc7b Only trim .odin from build filenames 2025-05-22 08:23:06 -04:00
Vincent Billet 1ed05c2498 Retracted some winmm changes 2025-05-22 12:15:16 +02:00
Vincent Billet 240d45201d Reverted CoCreateInstance formatting 2025-05-22 09:14:33 +02:00
Jeroen van Rijn f8bbeb54d4 Slight tweak. 2025-05-21 20:28:21 +02:00
Jeroen van Rijn c32b7ba593 List -subtarget in odin help build 2025-05-21 20:24:27 +02:00
Jeroen van Rijn 95183e4b9c Remove now unnecessary checks. 2025-05-21 19:37:09 +02:00
Jeroen van Rijn bd4134382b Merge pull request #5195 from Kelimion/fix-5177
Fix #5177
2025-05-21 19:28:38 +02:00
Jeroen van Rijn 96fd07e0ee Fix #5177 - Tweak error messages. 2025-05-21 19:20:58 +02:00
Jeroen van Rijn a2c0720fb0 Merge pull request #5194 from Feoramund/fix-5067
Fix off-by-one error in `priority_queue.remove`
2025-05-21 16:21:14 +02:00
Feoramund 1662ab10af Fix off-by-one error in priority_queue.remove 2025-05-21 09:33:39 -04:00
Jeroen van Rijn 96bbd944dc Merge pull request #5193 from Feoramund/compliant-win32-terminal
Also use `ENABLE_PROCESSED_OUTPUT` on Windows terminals
2025-05-21 14:50:48 +02: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
Jeroen van Rijn f65e418dc9 Merge pull request #5189 from Feoramund/fix-ansi-log-terminal
Add `core:terminal`, fix test runner/`core:log` ANSI code issues
2025-05-21 14:20:18 +02: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
gingerBill acb04160c5 Merge pull request #5190 from Feoramund/fix-freebsd-3rd-linking
Add `/usr/local/lib` to FreeBSD linker path
2025-05-21 09:42:07 +01:00
gingerBill 5af9e37e08 Merge pull request #5187 from laytan/no-libc-use-os2
os2: remove libc use on Linux for get_absolute_path
2025-05-21 09:41:30 +01:00
Vincent Billet b03cdd22d5 COM & Audio useful bindings 2025-05-21 09:48:41 +02: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
Jeroen van Rijn 4329f50d26 Merge pull request #5188 from deadwanderer/master
[vendor:directx/d3d12] Fix RESOURCE_STATE_ALL_SHADER_RESOURCE flags and add new HEAP_TYPE
2025-05-20 22:55:06 +02:00
deadwanderer 9f559af530 Add GPU_UPLOAD heap type 2025-05-20 15:45:03 -04:00
deadwanderer bcaba47e15 Fix incorrect resource state bit_set 2025-05-20 15:42:06 -04:00
Laytan Laats eab3e2be22 os2: remove libc use on Linux 2025-05-20 19:48:06 +02:00
Jeroen van Rijn 714066d91b Merge pull request #5186 from Kelimion/restore-cursor
Restore console mode when test runner exits.
2025-05-20 17:06:14 +02:00
Jeroen van Rijn 8bffd247b7 Restore console mode when test runner exits. 2025-05-20 16:51:24 +02:00
gingerBill e36db15b48 Fix typo _beginthreadx -> _beginthreadex 2025-05-20 09:16:14 +01:00
Jeroen van Rijn 50fcbb1058 Merge pull request #5183 from Feoramund/fix-5083
Do not call disabled deferred procedures
2025-05-20 02:58:38 +02:00
Feoramund b018528833 Do not call disabled deferred procedures 2025-05-19 20:50:43 -04:00
Jeroen van Rijn 91d6e5372c Merge pull request #5182 from Kelimion/dynamic-literals
-dynamic-literals
2025-05-19 20:53:23 +02:00
Jeroen van Rijn ab95932502 -dynamic-literals 2025-05-19 20:44:27 +02:00
Jeroen van Rijn b7783cac05 Merge pull request #5181 from Feoramund/fix-5167
Make `odin help` more precise
2025-05-19 15:38:09 +02: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
gingerBill bf0b69b2ec Merge pull request #5178 from Feoramund/enable-static-map-calls-sysv64
Re-enable static map calls on AMD64 SysV
2025-05-19 10:11:59 +01:00
Feoramund eb051a2d7c Re-enable static map calls on AMD64 SysV 2025-05-18 17:13:39 -04:00
gingerBill dd31075c33 Merge pull request #5171 from laytan/fix-global-and-static-any
fix global and static any
2025-05-18 16:59:34 +01:00
gingerBill 6a8c46bb36 Merge pull request #5175 from Feoramund/use-sysroot-on-darwin
Use `--sysroot` instead of `-Wl,-syslibroot` on Darwin
2025-05-18 16:58:59 +01:00
Laytan d3221425a7 Merge pull request #5172 from krnowak/krnowak/sys-linux-dirent-docs
sys/linux: Improve documentation for Dirent and related procedures
2025-05-18 17:47:41 +02: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
Krzesimir Nowak 3519cecb7c Formatting fixes 2025-05-18 15:25:17 +02:00
Jeroen van Rijn 558eca8c7a Merge branch 'master' of github.com:odin-lang/Odin 2025-05-18 15:08:21 +02:00
Jeroen van Rijn 1b13152286 Change XAudio2 DLL search flags to DEFAULT_DIRS 2025-05-18 15:08:10 +02:00
gingerBill 3e5110bb46 Minor style changes for sdl3 and sdl3/ttf 2025-05-18 11:20:55 +01:00
Krzesimir Nowak 306d3a16c4 sys/linux: Improve documentation for Dirent and related procedures 2025-05-17 20:05:51 +02:00
Laytan Laats c35a45e823 fix global and static any
Fixes #4627
2025-05-17 16:49:30 +02:00
Jeroen van Rijn d6210ae76f Fix -vet complaints in core:sys/darwin/Foundation 2025-05-17 16:36:10 +02:00
Jeroen van Rijn 7c80df4830 @(init), @(fini) and @(export) procedures are classified as used.
For the purposes of `-vet-unused-procedures`, exported procedures and `@(init)` and `@(fini)` are now disregarded.
2025-05-17 16:22:47 +02:00
gingerBill de4ed9a787 Merge branch 'master' of https://github.com/odin-lang/Odin 2025-05-17 13:28:03 +01:00
gingerBill 5454e120fe Add NSMenuItem.odin 2025-05-17 13:27:54 +01:00
gingerBill 8337b7cccb Merge pull request #5162 from 0xrsp/tounsigned
new compiler intrinsics type_integer_to_unsigned, type_integer_to_unsigned
2025-05-17 11:51:57 +01:00
gingerBill b5a8822296 Merge pull request #5170 from laytan/miniaudio-0.11.22
vendor/miniaudio: update to 0.11.22
2025-05-17 11:50:51 +01:00
gingerBill 63304af47e Merge branch 'master' of https://github.com/odin-lang/Odin 2025-05-17 11:36:30 +01:00
gingerBill d77124feae Add Objective-C helper for creating subclasses 2025-05-17 11:36:24 +01:00
Laytan 326454f0f0 generate xlib package docs on linux 2025-05-16 22:14:26 +02:00
Laytan 53a9ecb577 vendor/miniaudio: update to 0.11.22 2025-05-16 15:58:27 +02:00
Laytan d3159f74cd Merge pull request #4944 from dozn/master
[core:encoding/json] When Unmarshalling, Only Match On Struct Tags If Present
2025-05-15 22:31:34 +02:00
tf2spi 2f636886a5 Add debug info for labels (#4385)
* Emit label debug info w/o location

* Insert debug label call

* Slight refactor for later fix

* Improve debug labels for block statements

* Improve debug info with for loops

* Generate label lbBlocks w/ debug

* Lightly refactor lb_add_debug_label

* Revise comments, add null check assertion

* Use LLVM-C API for debug labels

* Prefer C DILabel API for POSIX, fallback to CPP

* Use version check for LLVM-C DILabel
2025-05-15 22:11:06 +02:00
Laytan Laats 2d00f8d69d fix compat with earlier llvm versions 2025-05-15 19:20:04 +02:00
0xrsp 649cad2f1b add: type_integer_to_* error messages 2025-05-15 01:12:06 +09:30
0xrsp cb0cab36b9 Merge branch 'tounsigned' of github.com:0xrsp/Odin into tounsigned 2025-05-15 01:02:57 +09:30
0xrsp ea806f1d5e new compiler intrinsics type_integer_to_unsigned,type_integer_to_signed 2025-05-15 01:00:40 +09:30
gingerBill 30b6750778 Add missing , 2025-05-14 15:14:02 +01:00
gingerBill cf6d26953e Merge pull request #5161 from deadwanderer/master
[vendor:directx/d3d12] - Add more D3D12 FEATURE_DATA_OPTIONs
2025-05-14 14:05:44 +01:00
deadwanderer 78f0992918 Fix bad whitespacing 2025-05-14 08:53:53 -04:00
deadwanderer 30434552a7 Adjust whitespace errors 2025-05-14 07:55:23 -04:00
gingerBill 4b8707f71b Merge pull request #5158 from A1029384756/master
[vendor:SDL/ttf] - GPUAtlasDrawSequence multipointer from pointer
2025-05-14 11:43:16 +01:00
deadwanderer 10a63ac498 Add more D3D12 FEATURE_DATA_OPTIONs 2025-05-13 23:45:58 -04:00
A1029384756 5379c8c1ac [vendor:sdl3/ttf] - changed indices to multipointer 2025-05-13 15:44:20 -04:00
A1029384756 82729d7e27 [vendor:SDL/ttf] - GPUAtlasDrawSequence multipointer from pointer 2025-05-13 15:40:40 -04:00
Jeroen van Rijn 25c935c305 Re-enable demo on *nix 2025-05-13 18:46:55 +02:00
Jeroen van Rijn 1a58476c03 Merge pull request #5155 from Kelimion/date_from_git
Parse odin version date out of HEAD commit if available
2025-05-13 18:45:16 +02:00
Jeroen van Rijn ed56a7ca10 Parse odin version date out of HEAD commit if available 2025-05-13 18:09:30 +02:00
gingerBill 0a12c464ab Change Odin's RTTI section name to .odinti 2025-05-13 08:58:02 +01:00
Jeroen van Rijn 7cd00483fe Merge pull request #5154 from Kelimion/os2-rollback
Revert "os2: Don't try to translate Windows file attributes to Unix m…
2025-05-12 23:41:25 +02:00
Jeroen van Rijn d7a83a7a1f Revert "os2: Don't try to translate Windows file attributes to Unix mode flags"
This reverts commit 95923c2059.
It'll be updated later.
2025-05-12 23:34:12 +02:00
gingerBill 4d7876bdb0 Merge branch 'master' of https://github.com/odin-lang/Odin 2025-05-12 16:50:11 +01:00
gingerBill d2d5c40e76 Handle "untyped" case 2025-05-12 16:49:59 +01:00
Jeroen van Rijn 8809ce2925 Merge pull request #5152 from Kelimion/mmap-flags
Update `linux.Map_Flags_Bits`
2025-05-12 17:23:39 +02:00
Jeroen van Rijn be24feb862 Move things to constants.odin 2025-05-12 17:13:59 +02:00
Jeroen van Rijn dec3d6959d Update linux.Map_Flags_Bits
Fixes #5151

- Removes `SHARED_VALIDATE` from the enum and turns it into `Map_Shared_Validate :: Map_Flags{.SHARED, .PRIVATE}` so it has the proper value of 0x03.
- Adds `DROPPABLE`.
- Adds constants `MAP_HUGE_SHIFT` and `MAP_HUGE_MASK`.
- Adds the huge page precomputed constants from `mman.h`, defined as the log2 of the size shifted left by `MAP_HUGE_SHIFT`:
	Map_Huge_16KB
	Map_Huge_64KB
	Map_Huge_512KB
	Map_Huge_1MB
	Map_Huge_2MB
	Map_Huge_8MB
	Map_Huge_16MB
	Map_Huge_32MB
	Map_Huge_256MB
	Map_Huge_512MB
	Map_Huge_1GB
	Map_Huge_2GB
	Map_Huge_16GB
2025-05-12 16:45:51 +02:00
gingerBill d2d4ac8120 Add compress_values 2025-05-12 15:29:43 +01:00
gingerBill 8e17ccfd98 Merge pull request #5142 from laytan/abi-and-asan-fixes
tests/internal with asan (requiring abi and codegen fixes), and macos -sanitize:address
2025-05-12 14:20:19 +01:00
gingerBill 223944ee88 Merge pull request #5147 from 0xrsp/master
add SDL_ttf bindings for SDL3 to vendor libraries
2025-05-12 14:14:34 +01:00
gingerBill bd4c062b98 Merge pull request #5145 from CoolDove/master
[vendor:raylib/rlgl] add 3 missing functions
2025-05-12 10:12:10 +01:00
Ben 0be7639c0a spelling in compilation errors 2025-05-11 22:10:16 -05:00
Jeroen van Rijn 39789bc6cb Make strings.to_cstring adhere to #optional_allocator_error 2025-05-12 01:17:34 +02:00
Jeroen van Rijn f6a39ca675 Merge pull request #5148 from Kelimion/fix-clean-path
Fix os2.clean_path on Windows
2025-05-11 15:44:40 +02:00
Jeroen van Rijn 30388cada3 Fix os2.clean_path on Windows 2025-05-11 15:35:52 +02:00
Dove 3c8cdf822f add 3 missing functions in vendor:raylib/rlgl 2025-05-11 04:03:51 +08:00
0xrsp 45c3361b43 SDL3_ttf: make SubStringFlags a bit_field 2025-05-11 00:25:31 +09:30
0xrsp ac1c97eb33 add: vendor SDL3_ttf 2025-05-11 00:23:29 +09:30
gingerBill ecd0655ba2 Merge pull request #5138 from laytan/os2-native-copy
os2: copy directory using walker & native copy setup and implementation on macos
2025-05-10 14:34:03 +01:00
gingerBill ffb4b36552 Merge pull request #5143 from laytan/strconv-hexfloats
add hexfloat (0h) parsing to strconv
2025-05-10 14:31:42 +01:00
Laytan Laats ebc63a7355 add hexfloat (0h) parsing to strconv 2025-05-10 15:11:52 +02:00
Laytan Laats 8374854dd5 use brew clang instead of system clang 2025-05-09 23:13:06 +02:00
Laytan Laats 221dea76a4 Run MacOS CI with -sanitize:address 2025-05-09 23:12:59 +02:00
Laytan Laats f9b9e9e7dc some ABI fixups and improvements
Started with trying to enable asan in the CI for MacOS, noticed it wasn't enabled on the `tests/internal`
folder, it came up with a couple of issues with the abi/OdinLLVMBuildTransmute that this also solves.

- Looking at clang output for arm64, we should be promoting `{ i64, i32 }` to `{ i64, i64 }`
- after doing the previous point, I noticed this is not handled well in OdinLLVMBuildTransmute
  which was emitting loads and stores into the space of a value that was alignment, asan does not want this,
  looking at clang output again, a memcpy is the appropriate way of handling this.
- Having done this we don't need the hacky "return is packed" set anymore in the amd64 sysv ABI anymore either
2025-05-09 23:03:17 +02:00
Laytan Laats 4d08b76372 require the __asan_unpoison_memory_region runtime symbol so empty projects with asan enabled build 2025-05-09 22:26:49 +02:00
Jeroen van Rijn e3fe733a55 Fix #5139 2025-05-09 19:45:46 +02:00
Jeroen van Rijn 3adade2639 Add .rdi RadDbg files to .gitignore 2025-05-09 19:42:54 +02:00
gingerBill 8a225a6887 Place RTTI into its own section .odin-rtti 2025-05-09 11:07:53 +01:00
gingerBill 23aff08556 Merge pull request #5117 from bogwi/bug/5024
Bug/5024
2025-05-09 08:35:16 +01:00
gingerBill 10d8332394 Merge pull request #5135 from Lperlind/asan-ci-tests
Enable asan for windows and ubuntu CI tests
2025-05-09 08:35:06 +01:00
Lucas Perlind 11d2a9c867 Enable asan for windows and ubuntu CI tests
Other platforms either do not support asan at all or they
fail to link with the asan runtime.
2025-05-09 15:39:39 +10:00
Laytan Laats cacb9f9f54 os2: better copy_directory, and add native copy_file and copy_directory variants on MacOS 2025-05-08 19:32:30 +02:00
gingerBill edbe7aa06e Merge pull request #5091 from Badaxis/badaxis/windows-scancodes
Adding windows keyboard scan codes
2025-05-08 16:33:14 +01:00
gingerBill 4a4294c2af Merge pull request #5095 from Lperlind/temp-collisions
os2: Resolve temp allocator collisions
2025-05-08 15:11:51 +01:00
gingerBill 204c6f514a Remove use of do 2025-05-08 14:03:17 +01:00
gingerBill 0ce8373528 Formatting Fix 2025-05-08 13:23:22 +01:00
gingerBill d7fc3d1770 Merge pull request #5121 from Badaxis/badaxis/xaudio2
XAudio2 Implementation
2025-05-08 13:11:51 +01:00
gingerBill 92df892f25 Merge pull request #5064 from harold-b/hb/objc-classes
Add support for Objective-C class implementation
2025-05-08 12:58:33 +01:00
Lucas Perlind f5b947ea73 Fix linux 2025-05-08 17:45:29 +10:00
Lucas Perlind 14c5096b81 Improve assert information 2025-05-08 17:41:03 +10:00
Lucas Perlind 9f2d008a8a Remove TEMP_ALLOCATOR_GUARD wrapper 2025-05-08 17:41:03 +10:00
Lucas Perlind 5292a7f4f3 Fix posix 2025-05-08 17:41:03 +10:00
Lucas Perlind 1bea59ee68 Fix linux 2025-05-08 17:41:03 +10:00
Lucas Perlind 190960e103 fix -vet 2025-05-08 17:41:03 +10:00
Lucas Perlind b9db1dd3e0 os2: Resolve temp allocator collisions 2025-05-08 17:41:01 +10:00
gingerBill ea65a7b870 Move raddbg string stuff to a thread-safe queue 2025-05-07 14:26:10 +01:00
gingerBill 4a709086a4 Merge pull request #5131 from laytan/fix-builder-dispose
fix disposing builder when not created
2025-05-07 14:03:42 +01:00
Laytan Laats ad4866653a fix disposing builder when not created
Fixes #5128

p->builder is created in lb_begin_procedure_body, but that isn't called
if there is no body, and we were still calling dispose at that point.

Moved it into lb_end_procedure_body to match.
2025-05-07 14:39:51 +02:00
gingerBill 0c4046b9ea Add #row_major matrix support for raddbg 2025-05-07 13:30:58 +01:00
gingerBill 833d77da1f Add column major matrix support 2025-05-07 13:20:14 +01:00
gingerBill 4274dfc5e2 Only add custom section for Windows (currently) 2025-05-07 11:44:49 +01:00
gingerBill e0125ccec2 Begin work on adding support for the .raddbg section for the RAD Debugger 2025-05-07 11:30:15 +01:00
gingerBill 90a30a145a Merge pull request #5122 from Lperlind/asan-allocators
Add asan support for various allocators and stack unpoisoning
2025-05-07 10:21:16 +01:00
Lucas Perlind 46e0c7ad74 Cleanup 2025-05-07 11:30:58 +10:00
Laytan 7c1a9f1e7a Merge pull request #5127 from laytan/fix-process-windows-handles-handling
Fix process windows handles handling
2025-05-06 22:31:54 +02:00
laytan 9b218a2922 don't need to hang on to the null handle 2025-05-06 19:42:52 +02:00
Laytan bf5206968a close null_handle 2025-05-06 20:57:26 +02:00
Laytan 2bce446d08 ifs wrong way around 2025-05-06 20:47:51 +02:00
Laytan 814a500e83 Windows was defaulting to the std handles of the current process, which is wrong 2025-05-06 20:43:02 +02:00
gingerBill 0cf5b5984d Merge pull request #5108 from Barinzaya/core-simd-indices-redadd-redmul
Alternate `reduce_add`/`reduce_mul` intrinsics
2025-05-06 15:46:49 +01:00
gingerBill e074518983 Merge pull request #5124 from Barinzaya/core-simd-bmi-intrinsics
BMI/BMI2 Intrinsics
2025-05-06 15:29:34 +01:00
Jeroen van Rijn 8097b59e30 Also allow comparing SOA pointers against each other
This compares the data pointer *and* the index.

```odin
package scratch

import "core:fmt"

Foo :: struct {a, b: int}

main :: proc() {
    a := new(#soa[dynamic]Foo)
    a^ = make(#soa[dynamic]Foo, 12, 12)

    b := new(#soa[dynamic]Foo)
    b^ = make(#soa[dynamic]Foo, 12, 12)

    fmt.printfln("&a[0]: %p, &b[0]: %p, Same: %v", &a[0], &b[0], &a[0] == &b[0]) // Same: false
    fmt.printfln("&a[0]: %p, &b[0]: %p, Same: %v", &a[0], &b[1], &a[0] == &b[1]) // Same: false
    fmt.printfln("&a[0]: %p, &b[0]: %p, Same: %v", &a[0], &b[2], &a[0] == &b[2]) // Same: false

    fmt.printfln("&a[0]: %p, &a[1]: %p, Same: %v", &a[0], &a[1], &a[0] == &a[1]) // Same: false
    fmt.printfln("&a[1]: %p, &a[2]: %p, Same: %v", &a[1], &a[2], &a[1] == &a[2]) // Same: false
    fmt.printfln("&a[2]: %p, &a[3]: %p, Same: %v", &a[2], &a[3], &a[2] == &a[3]) // Same: false

    fmt.printfln("&a[0]: %p, &a[0]: %p, Same: %v", &a[0], &a[0], &a[0] == &a[0]) // Same: true
    fmt.printfln("&a[1]: %p, &a[1]: %p, Same: %v", &a[1], &a[1], &a[1] == &a[1]) // Same: true
    fmt.printfln("&a[2]: %p, &a[2]: %p, Same: %v", &a[2], &a[2], &a[2] == &a[2]) // Same: true
}
```
2025-05-06 15:10:08 +02:00
Laytan e228ef221b Merge pull request #5125 from brian-hmn/fix-set-env
[core:os/os2] Fix: Correct value cloning in os2._set_env for POSIX
2025-05-06 12:24:17 +02:00
Jeroen van Rijn 9a8cc2d1e7 Merge pull request #5123 from bogwi/bug/5104
Bug/5104
2025-05-06 11:57:04 +02:00
Brian 27edbc5a76 Fix: Correct value cloning in os2._set_env for POSIX
The _set_env procedure in core/os/os2/env_posix.odin was
incorrectly cloning the 'key' argument for 'cval' instead of
the 'value' argument. This resulted in set_env effectively
setting the environment variable's value to its own key.

This commit corrects the typo to use the 'value' argument.
2025-05-06 17:45:06 +08:00
Barinzaya 41bf1ab6dd Added BMI and BMI2 intrinsics.
The BMI ones mostly aren't particularly interesting--they're mostly
trivially representable in-language--but PDEP and PEXT from BMI2 could
be.
2025-05-06 01:44:10 -04:00
Lucas Perlind fd05f55691 Fix wasi_wasm 2025-05-06 15:23:44 +10:00
bogwi 904a64a45e Add support for SoaPointer nil comparison in lb_emit_comp_against_nil 2025-05-06 14:21:18 +09:00
Lucas Perlind 83bc2d3c4a Add asan support for various allocators 2025-05-06 14:55:50 +10:00
Jeroen van Rijn 8032db3484 Fix CreateDibSection binding 2025-05-05 23:23:39 +02:00
Barinzaya dd5b7852ce Added alternate reduce-add/reduce-mul intrinsics.
The new reduce_add/reduce_mul procs perform the corresponding arithmetic
reduction in different orders than sequential order. These alternative
orders can often offer better SIMD hardware utilization.

Two different orders are added: pair-wise (operating on pairs of
adjacent elements) or bisection-wise (operating element-wise on the
first and last N/2 elements of the vector).
2025-05-05 16:38:45 -04:00
Barinzaya 9814370659 Merge branch 'master' into core-simd-indices-redadd-redmul 2025-05-05 16:37:02 -04:00
Vincent Billet b34a490c02 Corrections, +XAPO 2025-05-05 22:14:20 +02:00
Jeroen van Rijn 2224911aca Fix type_union_tag_offset when all members are zero sized 2025-05-05 18:09:54 +02:00
bogwi 3c0ba5bb55 CHECK 4 done
The original errors:
1. `5024.odin(127:15) Error: Invalid use of a polymorphic type 'List($T)' in variable declaration`
2. `5024.odin(129:17) Error: Cannot determine polymorphic type from parameter: 'invalid type' to 'List($T)'`
Are gone. We now have a single, different error:
`5024.odin(124:28) Error: Unspecialized polymorphic types are not allowed in procedure parameters, got List($T)`

This error points directly to the `list : List($T)` parameter within the `List_Filter` procedure definition. This seems much more relevant to the actual problem (the interaction between the generic `List_Filter` and the concrete `default_filter`) than the original error about the variable declaration.

While this new error message might not be exactly pinpointing the default parameter issue, it correctly identifies the problematic procedure definition (`List_Filter`) as the source of the error, rather than the variable declaration (`my_list`). This seems like a step in the right direction for improving the error reporting for this kind of scenario.
2025-05-05 22:39:03 +09:00
Harold Brenes 14e25c0f2a Fix lb_get_objc_type_encoding missing matrix and simdvec encodings and minor fixes. 2025-05-05 09:07:50 -04:00
gingerBill c4719e75fd Add simd.indices and docs 2025-05-05 11:43:19 +01:00
gingerBill 36945079f8 Add intrinsics.simd_indices 2025-05-05 11:41:54 +01:00
gingerBill bc2a4dfe9d Merge pull request #5110 from omark96/feat/get_window_thread_process_id
win/sys: Add GetWindowThreadProcessId
2025-05-05 10:17:29 +01:00
bogwi af6b763449 CHECK 3 done
Enhance support for polymorphic procedures in type checking

1. In src/check_type.cpp, added special handling for polymorphic procedures used as default parameter values. We now allow a polymorphic procedure to be used as a default parameter value, even when its type parameters can't be immediately determined.

2. In src/check_expr.cpp, we modified the check_is_assignable_to_with_score function to handle the special case of assigning a polymorphic procedure as a default parameter. The function now allows a polymorphic procedure to be assigned to a concrete procedure type in this specific context.
2025-05-05 17:53:32 +09:00
bogwi af0e067a12 CHECK 2 done
Add support for handling generic types in LLVM backend

- Updated `lb_type_internal` to return a pointer type for unspecialized generics.
- Modified `write_type_to_canonical_string` to handle specialized generics without panicking.
- Enhanced `default_type` to return the default type of specialized generics when applicable.
2025-05-05 16:58:14 +09:00
bogwi ee8aeea381 CHECK 1 done
Fix panic in LLVM backend when using generic procedure with default arguments

- Fixed panic in `llvm_backend_proc.cpp` when using unspecialized polymorphic procedures as defaults.
- Ensured correct type inference when generic procedures are used as default parameters.
2025-05-05 16:50:40 +09:00
Laytan 93f80f60fb Merge pull request #5112 from blob1807/master
`core:bufio`: Fix typo from `b.w-b.w` to `b.w-b.r`
2025-05-05 03:00:46 +02:00
Jeroen van Rijn 32cef4c11b Fix change_times on Windows and simplify time handling in stat 2025-05-04 22:55:27 +02:00
Jeroen van Rijn 1ce3a9f766 Merge pull request #5114 from Kelimion/os2-fixes
os2: Don't try to translate Windows file attributes to Unix mode flags
2025-05-04 20:21:44 +02:00
Jeroen van Rijn 95923c2059 os2: Don't try to translate Windows file attributes to Unix mode flags
Also, fix `chmod`. It passed the wrong struct size to `SetFileInformationByHandle`.
2025-05-04 20:03:07 +02:00
blob1807 39752faba4 Fix typo from b.w-b.w -> b.w-b.r 2025-05-04 15:48:26 +10:00
Jeroen van Rijn 0f2a4b80ef Proper fix for executable name on Linux. 2025-05-04 01:05:10 +02:00
Jeroen van Rijn deededfb0a Fix executable_path info on Linux 2025-05-04 00:21:20 +02:00
omark96 1b8a65c327 win/sys: Add GetWindowThreadProcessId 2025-05-03 23:44:55 +02:00
Barinzaya b0f53a6eaf Implemented suggestions on core:simd helpers.
Adjusted documentation, and renamed the reduce_*_split procs to
reduce_*_bisect.
2025-05-03 17:35:53 -04:00
Jeroen van Rijn c96d8237ba Clarify error messages for types that aren't simply comparable.
Previously, it implied that these are different types:
```
W:/Scratch/scratch.odin(17:5) Error: Cannot compare expression, operator '==' not defined between the types 'Handle_Map($T=u32, $HT=u32, $Max=10000)' and 'Handle_Map($T=u32, $HT=u32, $Max=10000)'
    if m == {} {
       ^~~~~~^
```
Now:
```
W:/Scratch/scratch.odin(20:5) Error: Cannot compare expression. Type 'Handle_Map($T=u32, $HT=u32, $Max=10000)' is not simply comparable, so operator '==' is not defined for it.
	if m == {} {
	   ^~~~~~^
```
2025-05-03 22:31:01 +02:00
Barinzaya 6ebd30033f Removed an extra character that slipped into a comment. 2025-05-03 13:24:22 -04:00
Harold Brenes be2e4dec7d Resolve other TODOs 2025-05-03 13:06:57 -04:00
Barinzaya 8b6436201e Fixed a reduce_add proc doing multiplication instead. 2025-05-03 13:04:11 -04:00
Barinzaya 7e34d707bb core:simd helpers: indices and reduce_add/mul
The indices proc simply creates a vector where each lane contains its
own lane index. This can be useful for use in generating masks for loads
and stores at the beginning/end of slices, among other things.

The new reduce_add/reduce_mul procs perform the corresponding arithmetic
reduction, in different orders than just "in sequential order". These
alternative orders can often be faster to calculate, as they can offer
better SIMD hardware utilization.

Two different orders are added for these: pair-wise (operating on
adjacent pairs of elements) or split-wise (operating element-wise on the
two halves of the vector).

This doesn't actually cover the *fastest* way for arbitrarily-sized
vectors. That would be an ordered reduction across the native vector
width, then reducing the resulting vector to a scalar in an appropriate
parallel fashion. I'd created an implementation of that, but it required
multiple procs and a fair bit more trickery than I was comfortable with
submitting to `core`, so it's not included yet. Maybe in the future.
2025-05-03 11:55:52 -04:00
Jeroen van Rijn 9681d88cd3 Fix #5107
Fixes #5107 by checking whether `result_count` is non-zero before indexing `type->Proc.results->Tuple.variables`.
2025-05-03 14:42:20 +02:00
Harold Brenes fc082f5ea5 Remove some TODO. Leave important note 2025-05-03 03:21:03 -04:00
Harold Brenes 6d18560ca3 Move unconditionally exporting Objective-C methods to the right location 2025-05-03 03:09:31 -04:00
Harold Brenes cf3830a6a8 Fix checker errors. 2025-05-03 03:09:31 -04:00
Harold Brenes 33d37c72f9 Register all classes unconditionally 2025-05-03 03:09:31 -04:00
Harold Brenes a00b91577d Prevent multiple uses of the same Objective-C class name 2025-05-03 03:09:30 -04:00
Harold Brenes 5f0b47c373 Implement all checker specification for Objective-C class implementations and objc_ivar_get intrinsic 2025-05-03 00:59:33 -04:00
Jeroen van Rijn 30c6fea9e9 Allow polymorphic #simd array as return type 2025-05-02 15:38:43 +02:00
gingerBill 19fe75f020 Merge pull request #5098 from laytan/fix-nan-comparisons
fix variable NaN comparisons
2025-05-02 13:00:42 +01:00
Jeroen van Rijn 7027d37596 Merge pull request #5103 from jasonKercher/better-box2d-build
Make build_box2d.sh more flexible
2025-05-02 04:57:58 +02:00
jason 87f5b96fcc Make build_box2d.sh more flexible
Removed the `odin root` call.
Seperated the clean rule in wasm.Makefile to enable parallel builds.
2025-05-01 22:42:32 -04:00
gingerBill 777c33a9a1 Merge pull request #5102 from Lperlind/attribute-no-sanitize-address
Add attribute @(no_sanitize_address)
2025-05-01 12:16:10 +01:00
Lucas Perlind 5c73b4ef58 Add attribute @(no_sanitize_address)
The purposes of this attribute is to let procedures opt-out of being
instrumented with asan. Typically an allocator that includes 'in-band'
meta-data will be accessing poisoned values (such as tlsf).

Making asan work with these allocators becomes very challenging so
just being to ignore asan within specific allocator procedures
makes it easier to reason and removes the need to temporarily
poison and unpoison allocator data.
2025-05-01 20:42:21 +10:00
Harold Brenes 0746127654 Minor fixes in data type usage and style. 2025-04-30 22:16:53 -04:00
Harold Brenes 1505edef01 Change ivar offsets from u32 to (odin base type) int/native pointer size. 2025-04-30 22:09:33 -04:00
Harold Brenes dc8692b504 Use correct alignment value for class_addIvar. 2025-04-30 21:52:29 -04:00
Harold Brenes 998ed79738 Go back to objc_ivar_get instead of ivar_get. 2025-04-30 20:43:05 -04:00
Harold Brenes c2dfc4b749 Cleanup ivar generation for selector expressions.
Cleanup ObjC superclass resolution.
2025-04-30 20:32:34 -04:00
Harold Brenes abfbb2f9ed Use basic name instead of raw_name for type encoding complex and quats. 2025-04-30 20:32:28 -04:00
Harold Brenes 668a9a89b0 Complete lb_get_objc_type_encoding() implementation 2025-04-30 20:32:14 -04:00
Harold Brenes 5097e98da2 Better Objective-C object superclass cycle check 2025-04-30 20:32:05 -04:00
Harold Brenes 2dc5653fd1 Name fixes 2025-04-30 20:31:54 -04:00
Jeroen van Rijn 2d8ae2d23c Merge pull request #5100 from herohiralal/patch-1
Convention-related changes in `file_windows.odin`
2025-04-30 22:27:59 +02:00
Rohan Jadav f50698b901 updated file_windows.odin to follow coding conventions 2025-05-01 00:56:31 +05:30
Laytan dd0b8d5757 Merge pull request #5099 from laytan/add-alias-issue-tests-to-ci
adds the cases of #5043 and #5097 to the CI
2025-04-30 20:20:43 +02:00
Laytan Laats d2f8cb1306 adds the cases of #5043 and #5097 to the CI 2025-04-30 20:13:21 +02:00
Laytan Laats 396a18efce fix variable NaN comparisons 2025-04-30 20:04:24 +02:00
Laytan c74f777b1b Merge pull request #5097 from laytan/fix-pointer-alias-type-check
fixes assigning null as a type if it's an alias but the base type is null
2025-04-30 19:54:48 +02:00
Laytan Laats 9fb9382449 fixes assigning null as a type if it's an alias but the base type isn't resolved yet
It's a bit of a band aid fix because the field will get the type of the
alias, not the base type, but that was already the case before #5045 so
it's forward progression.

Closes #5092
Fixes #5061
2025-04-30 19:39:38 +02:00
Vincent Billet 125b60aee0 First implementation of XAudio2 2025-04-30 17:32:11 +02:00
gingerBill e64bcc7709 Merge pull request #5088 from leecommamichael/master
vendor:wasm/WebGL: Fix incorrect parameter types
2025-04-30 13:24:00 +01:00
Jeroen van Rijn b04a83ce9f Merge pull request #5096 from jdennis9/master
os2: Fix reading directory on Windows sometimes failing to decode a file name following one with exotic unicode characters
2025-04-30 12:10:09 +02:00
Jamie Dennis ff0eac2a71 os2: Use win32_wstring_to_utf8 over win32_utf16_to_utf8 when converting FIND_DATAW to File_Info 2025-04-30 21:38:17 +12:00
Michael Lee 757ae5e270 Merge branch 'odin-lang:master' into master 2025-04-29 17:11:10 -05:00
gingerBill 0de802d388 All N-valued (N>=2) expressions in or_else expressions 2025-04-29 17:39:28 +01:00
Vincent Billet d24bac8a36 Adding windows keyboard scan codes 2025-04-29 18:00:41 +02:00
Michael Lee 9c5fa073df Update webgl.odin 2025-04-29 10:52:11 -05:00
Jeroen van Rijn 7c294a6e55 Merge pull request #5090 from Barinzaya/cbor-fix-unmarshal-slice-overflow
Fixed CBOR Slice Overflow
2025-04-29 14:34:16 +02:00
Barinzaya 3f5e09a0df Fixed an overflow when decoding a large CBOR slice.
The initial allocation for the slice is limited to prevent untrusted
data from forcing a huge allocation, but then the dynamic array was
created with a capacity of the unlimited length, rather than the actual
capacity of the allocation. This was causing a buffer overrun.
2025-04-29 08:19:43 -04:00
gingerBill 03dcff59e8 Merge pull request #5089 from Lperlind/asan-docs
Document base:sanitizer
2025-04-29 13:19:00 +01:00
Lucas Perlind 4763da4b0d Document base:sanitizer 2025-04-29 19:06:09 +10:00
Michael Lee 808eec8e23 Fix incorrect parameter types 2025-04-28 20:24:41 -05:00
Jeroen van Rijn 4f00224dd2 Add cbor.unmarshal_from_bytes taking a []byte 2025-04-29 01:10:15 +02:00
Jeroen van Rijn 8c47d42394 Fix lru.remove 2025-04-29 00:14:46 +02:00
Jeroen van Rijn 26f1cb493e Merge pull request #5087 from elyalon/typo
Fix typo in private function
2025-04-28 21:25:10 +02:00
Ely Alon 13566306d2 Fix typo in private function 2025-04-28 22:03:20 +03:00
Lucas Perlind 51d427f424 Remove vet explicit allocators from cli 2025-04-28 19:33:37 +10:00
Harold Brenes 89533f49e4 Fix more styling and minor issues 2025-04-27 23:05:17 -04:00
Harold Brenes f3923ed666 Fix indentations
Fix Objective-C wrapper procs not forwarding return value
2025-04-27 22:55:53 -04:00
Harold Brenes 6c9c239a5e Fix styling issues 2025-04-27 22:55:53 -04:00
Lucas Perlind 65b4c793f0 Add -vet-explicit-allocators
This vet flag will make it so that allocators must be explicitly used
in places where context.allocator and context.temp_allocator are a
procedure parameter.

The goal of this flag is to prevent using the context.allocator in
cases where a different allocator was meant to be used.
Some code bases default context.allocator to nil/panic allocator
to catch this at runtime. This effectively makes it a compile
time error instead.
2025-04-27 22:47:03 +10:00
Jeroen van Rijn d463aba7d1 Warn if someone imports the same case-folded path twice 2025-04-27 14:32:26 +02:00
Colin Davidson f1fdd1a8b9 Merge branch 'master' into macharena 2025-04-26 18:22:21 -07:00
Colin Davidson 78d8ed2d39 Merge branch 'master' into macharena 2025-04-26 15:04:02 -07:00
Jeroen van Rijn 7d4c3d23e6 Merge pull request #5079 from herohiralal/master
Pipe size on windows.
2025-04-26 23:05:16 +02:00
Rohan Jadav 80a6f8928a fix: Pipe size on windows. 2025-04-27 01:58:37 +05:30
Laytan Laats 6c1a3c4f0c box2d: fix World_CollideMover 2025-04-25 18:24:41 +02:00
gingerBill f3cc734b39 Add copy_directory 2025-04-25 09:01:53 +01:00
gingerBill b5c658a2cf Merge pull request #5069 from laytan/box2d-3.1.0
box2d: update to 3.1.0
2025-04-25 08:26:43 +01:00
gingerBill 9f30380712 Merge pull request #5072 from Lperlind/asan
Add more asan support to the odin runtime and begin sanitizing allocators
2025-04-25 08:24:18 +01:00
gingerBill b83809779b Merge pull request #5075 from Barinzaya/global-var-alignment
Fix Global/Static Variable Alignment
2025-04-25 08:23:48 +01:00
Barinzaya 9284ebb5e8 Add missing cast to global/static var alignments. 2025-04-24 14:35:00 -04:00
Barinzaya b41a776027 Correctly align global and static variables.
This can be important if matrices or SIMD vectors are being used in
global or static variables, as otherwise it may result in crashes due to
aligned instructions accessing misaligned variables.
2025-04-24 14:21:21 -04:00
Jeroen van Rijn cfb478808e Merge pull request #5074 from Barinzaya/time-tick-add
Add `tick_add` proc to `core:time`
2025-04-24 15:28:58 +02:00
Barinzaya 6400693197 Added tick_add proc to core:time. 2025-04-24 09:20:31 -04:00
Lucas Perlind 5e985bcd74 Remove dependency on runtime; Add to examples 2025-04-24 20:34:32 +10:00
Lucas Perlind 5c117bde6d Add base:sanitizer package 2025-04-24 20:28:32 +10:00
Lucas Perlind 7502e7f2bc make asan procs contextless 2025-04-24 19:56:40 +10:00
Lucas Perlind 4a0be1f3a8 make vet happy 2025-04-24 16:02:31 +10:00
Lucas Perlind ab0b26e876 Add more asan support to the odin runtime and begin sanitizing
allocators

This adds various bindings to the asan runtime which can be used
to poison/unpoison memory handed out by various allocators. This
means we can catch use after free memory bugs when using operations
such as free_all during runtime.

Asan poisoning are added for the follow allocators in mem:
Arena (including temporary arenas)
Scratch
Stack
Small_Stack

Additionally a bug in the stack allocator was fixed to disallow freeing
in the middle of the stack (caught by the asan!).

I plan on adding support for all the allocators in core. This is just
a good starting point and were some of the easiest ones to implement
asan for.
2025-04-24 15:17:51 +10:00
laytan 38f56c0ede box2d: update windows libs to 3.1.0 and call thread.yield in vendor/libc 2025-04-23 16:59:54 +02:00
Harold Brenes 974a197ce1 Allow the class's ivar to be used as a context provider receiver as well. 2025-04-23 02:06:01 -04:00
Harold Brenes 47abea1229 Add support for Objective-C method implementation with Odin calling convention.
Use @objc_context_provider to provide a context for a type.
2025-04-23 02:05:51 -04:00
Harold Brenes 730c844fc6 Fix bug in @encode implementation. 2025-04-23 02:05:43 -04:00
Harold Brenes 53adff38f0 Fixes to Ivar pseudo fields. 2025-04-23 02:05:33 -04:00
Harold Brenes bca02f81cd Include the ivar in the Objective-C class unconditionally of it being used or not.
Allow pseudo-fields for ivar access.
2025-04-22 19:18:53 -04:00
Laytan Laats e086151fcd box2d: update to 3.1.0 2025-04-22 22:38:15 +02:00
mtarik34b c7f9d2b1b7 Correctly capitalize 'E' for the %E format specifier (#5065) 2025-04-22 02:35:02 +02:00
Jeroen van Rijn 47f889569f Fix float64_range example 2025-04-21 18:37:57 +02:00
Harold Brenes b3b4d501ca Fix ivar in multi-module mode. 2025-04-21 02:43:16 -04:00
Harold Brenes a3de9c8de4 Add initial support for Objective-C class implementation 2025-04-20 21:53:46 -04:00
Jeroen van Rijn ab5ca087a7 Add comment 2025-04-19 23:44:02 +02:00
Jeroen van Rijn 062a3c2fae Fix parsing of CDATA tags (#5059)
Fixes #5054
2025-04-19 20:25:44 +02:00
Jeroen van Rijn bc86b50392 Replace default_tcp_options with constant (#5056)
Replace `default_tcp_options` with constant
2025-04-19 14:32:59 +02:00
Jeroen van Rijn d10cb91e3f Merge pull request #5053 from fendevel/fix/sdl3-display-binding
SDL3: Fix `count` output parameter of `GetFullscreenDisplayModes`
2025-04-18 19:45:45 +02:00
Jack Fenech 27ee425ac5 Fix count output parameter of GetFullscreenDisplayModes 2025-04-18 18:07:43 +01:00
gingerBill 4374685007 Merge pull request #5042 from fusion32/fix-once-do-without-data-contextless
make once_do_without_data_contextless actually contextless
2025-04-18 11:47:10 +01:00
Laytan 2dedb199b8 Merge pull request #5052 from harold-b/hb/fix-ns-dictionary-selectors
Fix 2 selectors in NSDictionary
2025-04-17 21:28:10 +02:00
Harold Brenes 040d8b1d48 Fix 2 selectors in NSDictionary 2025-04-17 15:22:10 -04:00
Jeroen van Rijn 07c59cb4db Early out and propagate nil in create*
If allocation of a `^Thread` failed, `create*` now properly return `nil`,
so you can assert on that instead of calling `thread.destroy` on a null pointer, say.
2025-04-17 17:26:24 +02:00
Jeroen van Rijn 1c655b84e4 Fix #5049
Keep in mind that `thread.create` needs an allocator to be set, as it returns `^Thread`.
2025-04-17 16:53:07 +02:00
Jeroen van Rijn 8985d3beb3 Merge pull request #5050 from Kelimion/pq-err
Let `core:container/priority_queue` return `runtime.Allocator_Error`
2025-04-17 14:35:04 +02:00
Jeroen van Rijn 5a39013339 Let core:container/priority_queue return runtime.Allocator_Error
`init`, `reserve` and `push` now return `runtime.Allocator_Error`.
2025-04-17 14:20:03 +02:00
Laytan 09c8477bd3 Merge pull request #5041 from mtarik34b/remove-redundant-code-in-string-justify
Remove redundant `builder_init()` calls from `strings.left_justify()` and `strings.right_justify()`
2025-04-17 00:01:59 +02:00
Jeroen van Rijn 81274a7d67 Merge pull request #5045 from laytan/fix-not-resolving-to-alias-in-a-recursive-declaration
fix not resolving to alias in a recursive declaration
2025-04-16 23:07:01 +02:00
Laytan 8efeaef40b fix not resolving to alias in a recursive declaration 2025-04-16 22:55:25 +02:00
Jeroen van Rijn 3ba9b9b14e Merge pull request #5044 from Barinzaya/box2d-missing-allowfastrotation
Add missing field in box2d.BodyDef
2025-04-16 21:56:22 +02:00
Barinzaya 744587e082 Added missing allowFastRotation field to box2d.BodyDef. 2025-04-16 15:49:36 -04:00
fusion32 bd4afafc66 make once_do_without_data_contextless actually contextless 2025-04-16 12:44:00 -03:00
gingerBill 4ec03a2d9b Fix strconv.parse_float related procedures caused by a shifting problem 2025-04-16 13:45:50 +01:00
mtarik34b f4212b60e7 Remove redundant calls to builder_init 2025-04-16 13:16:51 +02:00
gingerBill 3dcc22fa6d Change hashing rules for float-like types to make 0 == -0 2025-04-16 10:52:35 +01:00
Laytan 990cc56974 sdl3: fix not allowing nil for SetWindowMouseRect 2025-04-15 20:13:51 +02:00
Jeroen van Rijn 678fa897f5 signbit -> sign_bit in tests/core/math 2025-04-15 16:20:49 +02:00
Jeroen van Rijn ddedddc16d Get rid of duplicate math.signbit in favor of math.sign_bit 2025-04-15 16:17:02 +02:00
gingerBill 6045955c88 More improvements doc writer name canonicalization 2025-04-15 12:35:20 +01:00
gingerBill b2ca76a76a Improve name canonicalization rules for the doc writer 2025-04-15 12:07:58 +01:00
gingerBill cfb8cc709c Merge branch 'master' of https://github.com/odin-lang/Odin 2025-04-15 11:51:05 +01:00
gingerBill 39363c4018 Improve name canonization rules for doc writer 2025-04-15 11:50:59 +01:00
Jeroen van Rijn 2d5b85f9f9 Merge pull request #5038 from mtarik34b/noteq-comparison-for-nan-must-be-true
Ensure `NaN != any_float_value` evaluates to true for constant NaN values
2025-04-15 12:29:17 +02:00
gingerBill 753c3fa0a7 Merge branch 'master' of https://github.com/odin-lang/Odin 2025-04-15 11:26:48 +01:00
gingerBill 2d4cb79baa Fix SysV ABI bug 2025-04-15 11:26:41 +01:00
mtarik34b 1d2adbb3c6 Remove reference to git issue 2025-04-15 05:26:36 +02:00
mtarik34b 313d7d84bc Ensure NaN != any_float_value evaluates to true for constant NaN values 2025-04-15 05:00:36 +02:00
Laytan 11da543f26 net: add ECONNRESET to the error handling of recv 2025-04-14 21:17:22 +02:00
Jeroen van Rijn 0fc141db5d core:mem/tlsf: Add early-out in OOM logic
This implementation doesn't allow for out-of-band allocations to be passed through, as it's not designed to
track those. Nor is it able to signal those allocations then need to be freed on the backing allocator,
as opposed to regular allocations handled for you when you `destroy` the TLSF instance.

So if we're asked for more than we're configured to grow by, we can fail with an OOM error early, without adding a new pool.
2025-04-14 20:40:05 +02:00
ed 18683c6172 Merge tag 'dev-2025-04' 2025-04-14 14:36:56 -04:00
ed 5bd4b6fb21 update build script 2025-04-14 14:32:36 -04:00
Jeroen van Rijn 3d13beb3ec Remove now-implemented TODO 2025-04-14 20:09:55 +02:00
Jeroen van Rijn 11af4cebb7 Merge pull request #5037 from Kelimion/tlsf
Allow `core:mem/tlsf` to automatically add new pools.
2025-04-14 20:00:39 +02:00
Jeroen van Rijn beee27dec0 Allow core:mem/tlsf to automatically add new pools.
New features:
- If TLSF can't service an allocation made on it, and it's initialized with `new_pool_size` > 0, it will ask the backing allocator for additional memory.

- `estimate_pool_size` can tell you what size your initial (and `new_pool_size`) ought to be if you want to make `count` allocations of `size` and `alignment`, or in its other form, how much backing memory is needed for `count` allocations of `type` and its corresponding size and alignment.
2025-04-14 19:49:55 +02:00
Jeroen van Rijn 66d99c1be3 Merge pull request #5036 from Kelimion/tlsf
Refactor `core:mem/tlsf`, add `free_all` support.
2025-04-14 17:30:46 +02:00
Jeroen van Rijn 7088284ff4 Refactor core:mem/tlsf, add free_all support.
TODO: Allow the TLSF allocator to add additional pools when it would ordinarily OOM
      by calling its backing allocator.
2025-04-14 17:13:27 +02:00
Jeroen van Rijn 9516084e58 Merge pull request #5035 from Sojamann/sync_chan-maintainance
core:sync/chan: maintainance and package clarity
2025-04-13 23:13:07 +02:00
Robin Bergewski 1c6958d443 core:sync/chan: maintainance and package clarity
this deprecates all procedures around 'Raw_Queue' for it to
become package private.
2025-04-13 22:56:40 +02:00
Jeroen van Rijn a98cbe2cc9 Merge pull request #5034 from Kelimion/yeet-tuple
Remove Type_Info_Tuple
2025-04-13 21:59:32 +02:00
Jeroen van Rijn bb38775fb1 Remove Type_Info_Tuple 2025-04-13 21:51:57 +02:00
Laytan ddcd7a368b Merge pull request #5033 from jasonKercher/fix-dirent-name
Fix linux.dirent_name
2025-04-13 18:14:02 +02:00
jason 4998d4ebd0 Fix linux.dirent_name
Was not searching the first possible byte for 0.
2025-04-13 12:05:39 -04:00
Jeroen van Rijn c10cf312ff Merge pull request #5032 from Sojamann/sync_chan-doc
core:sync/chan: add package documentation
2025-04-13 17:09:18 +02:00
Robin Bergewski 4ec93ffe39 fix indent 2025-04-13 16:40:08 +02:00
Robin Bergewski ec71a5afb1 fix missing imports 2025-04-13 16:33:25 +02:00
Robin Bergewski 19eb53c321 changes due to review 2025-04-13 15:34:14 +02:00
Jeroen van Rijn 0e9cd0fb6a Prepare for tlsf.free_all 2025-04-13 15:20:53 +02:00
Robin Bergewski ca72aba9eb core:sync/chan: add package documentation 2025-04-13 15:07:06 +02:00
Laytan Laats 74a66f7794 os2: fix get_executable_path() on FreeBSD including the nil-terminator 2025-04-12 21:33:44 +02:00
Jeroen van Rijn 32c9f6d13a Remove bit_field -> bit_set warning.
The "This 'bit_field' might be better expressed as a 'bit_set' since all of the fields are booleans, of 1-bit in size, and the backing type is an integer" warning is imperfect. Disable it for now.
2025-04-12 14:01:18 +02:00
Jeroen van Rijn 0a97e01827 Add tests for type_elem_type on SIMD vectors 2025-04-11 23:31:02 +02:00
Jeroen van Rijn 29b03adab1 Merge pull request #5030 from Kelimion/type_elem_type
Allow intrinsics.type_elem_type(simd_vector) to return the element type.
2025-04-11 22:51:28 +02:00
Jeroen van Rijn 41d4ddbc5e Add reflect.length + reflect.capacity support for #simd[N]T 2025-04-11 22:44:02 +02:00
Jeroen van Rijn f4ce84dfb4 Add fix to reflect.typeid_elem 2025-04-11 22:24:19 +02:00
Jeroen van Rijn 04807309b7 Allow intrinsics.type_elem_type(simd_vector) to return the element type.
Make `type_elem_type(#simd[4]f32)` return `f32`, same as it would for `[4]f32`.
2025-04-11 21:49:48 +02:00
Laytan 23a2821353 Merge pull request #5028 from Feoramund/fix-macos-version-reporting
Fix Darwin version reporting for older macOS
2025-04-10 22:37:45 +02:00
Feoramund 840c863786 Fix Darwin version reporting for older macOS 2025-04-10 16:25:08 -04:00
Jeroen van Rijn b27008e0f9 Simplify condition, op = Token_Sub was trivially true 2025-04-10 17:58:54 +02:00
Jeroen van Rijn 3a7691c714 Fixes #5026 2025-04-10 17:54:58 +02:00
gingerBill 1980ad8851 Merge pull request #4998 from dozn/patch-1
[core:time/timezone] Nanoseconds Not Preserved on Calls to `timezone.datetime_to_tz`
2025-04-10 14:01:25 +01:00
gingerBill 77d6cc1e90 Merge pull request #5025 from openhood/wgpu-fix-wrong-function-name
Fix wrong function name from `genericAdapterInfo` to `genericGetAdapterInfo` in wgpu.js
2025-04-10 14:00:58 +01:00
gingerBill 8629e5c958 Keep -vet happy 2025-04-10 11:41:05 +01:00
gingerBill 1f814c33dc Support subtargets in build tags: #build darwin:generic and #build linux:android, darwin:ios 2025-04-10 11:36:03 +01:00
gingerBill 5e63388de2 Fix init_android_values SDK check for odin check 2025-04-10 11:07:44 +01:00
Jonathan Tron 57a92259d7 Fix wrong function name from genericAdapterInfo to genericGetAdapterInfo in wgpu.js 2025-04-10 12:02:45 +02:00
Jeroen van Rijn 5912718002 Merge pull request #5023 from justgook/master
add quotes for absolute path
2025-04-09 14:39:31 +02:00
gingerBill 2548fc2431 Actually maybe fix #5015 2025-04-09 13:33:06 +01:00
Romāns Potašovs dc75ee72ae add quotes for absolute path 2025-04-09 15:31:34 +03:00
gingerBill a15b367921 Fix #5015 2025-04-09 13:29:56 +01:00
gingerBill 377e4e11ed Merge branch 'master' of https://github.com/odin-lang/Odin 2025-04-09 13:23:21 +01:00
gingerBill a66ea9bf4a Remove warning on struct field parameters being too big for the stack 2025-04-09 13:23:15 +01:00
Jeroen van Rijn d401a089c8 Merge pull request #5022 from IllusionMan1212/fix-printing-long-strings
gb.h: fix buffer overflow when printing long strings.
2025-04-09 07:37:59 +02:00
IllusionMan1212 640325512b gb.h: fix buffer overflow when printing long strings. fix #4831 2025-04-09 00:31:54 +02:00
Jeroen van Rijn dd826b759f Merge pull request #5021 from flysand7/fix-badge
Fix the CI badge URL
2025-04-08 22:55:58 +02:00
flysand7 c95742ff2b Fix the CI badge URL 2025-04-09 07:46:44 +11:00
gingerBill fbd29dd409 Merge pull request #5013 from IllusionMan1212/one-last-android-fix-maybe
fix: use the clang binary that's provided by the android NDK
2025-04-08 13:14:20 +01:00
gingerBill 145dac5b75 Merge pull request #5016 from Barinzaya/fix-math-nextafter
Fix `math.nextafter` skipping from 0 to 1
2025-04-08 13:13:51 +01:00
gingerBill b07387321a Merge branch 'master' of https://github.com/odin-lang/Odin 2025-04-08 11:37:42 +01:00
gingerBill fe040d1bbd Propagate @(link_section=<string>) to nested declarations 2025-04-08 11:36:53 +01:00
Jeroen van Rijn 329b15961a Don't run demo if building Odin fails.
`cl`'s return value was stomped by `mt`, so we ran the demo if `cl` failed, but `mt` succeeded.
This obscures `cl`'s output, so we're now checking both for errors.
2025-04-08 11:44:35 +02:00
Jeroen van Rijn eeb8b8dcc4 Fix #5020 2025-04-08 10:13:45 +02:00
IllusionMan1212 af91dd7c7a android: always link liblog 2025-04-08 01:30:55 +02:00
Barinzaya bbaec119e5 Added tests for math.nextafter. 2025-04-07 16:27:41 -04:00
Jeroen van Rijn 44bd2d3750 Merge pull request #5019 from Cararasu/master
vendor/glfw: fix SetMonitorCallback and MonitorProc type definition
2025-04-07 22:24:08 +02:00
Thomas Wagner 447177e486 vendor/glfw: fix SetMonitorCallback and MonitorProc type definition
SetMonitorCallback does not take a WindowHandle and MonitorProc
has a MonitorHandle as the first argument.
2025-04-07 22:13:29 +02:00
Jeroen van Rijn d77b8aeaa1 Merge pull request #5018 from Barinzaya/fix-fmt-bitset-nonzero-enum
Fix printing of `bit_set[Enum]` when `min(Enum) != 0`
2025-04-07 22:01:19 +02:00
Barinzaya 92ac86ae3c Fixed fmt handling of bit_set[Enum] when min(Enum) != 0.
The lower bound of the `bit_set` was only being applied *after*
searching for a matching enum value, so values wouldn't line up if the
minimum value of the enum wasn't 0.
2025-04-07 15:41:21 -04:00
Jeroen van Rijn 716bd479a9 Disallow .Multiline in iterator. 2025-04-07 21:33:57 +02:00
Barinzaya bffa0eaa58 Fixed math.nextafter procs skipping from 0 to 1. 2025-04-07 13:38:10 -04:00
Jeroen van Rijn 2b26c0b39e Remove now unused field. 2025-04-07 15:02:36 +02:00
Jeroen van Rijn a5e513567b Optimize regex match iterator.
Reuse virtual machine and capture groups between matches.
2025-04-07 14:58:41 +02:00
Jeroen van Rijn c13b68f103 Fix os2/process defer error. 2025-04-07 13:33:21 +02:00
Jeroen van Rijn 3287e1b0f0 Fix HXA defer warning 2025-04-07 13:19:00 +02:00
IllusionMan1212 7d2a8dc8ee fix: use the clang binary that's provided by the android NDK
always link against libandroid because it's needed by the glue code.
2025-04-07 13:02:14 +02:00
gingerBill 77b5eebf8c Add trivial sanity check for assigning to return values within defer #5011 2025-04-07 11:57:55 +01:00
Jeroen van Rijn bee158d53a Merge pull request #5010 from Feoramund/fix-netbsd-arm64-syscall
Fix `syscall_bsd` on NetBSD ARM64
2025-04-07 11:30:13 +02:00
Feoramund e13b05168c Fix syscall_bsd on NetBSD ARM64 2025-04-06 19:58:23 -04:00
Jeroen van Rijn 9a2b6c01aa Return loop index in regex iterator. 2025-04-06 21:45:37 +02:00
Jeroen van Rijn 66077add33 {.Glboal} implicit in regex allocator. 2025-04-06 21:13:02 +02:00
Jeroen van Rijn 07a79254e0 Merge pull request #5008 from Kelimion/regex-iterator
Add iterator for `core:text/regex`.
2025-04-06 14:32:50 +02:00
Jeroen van Rijn 918d57fe01 Keep -vet happy. 2025-04-06 14:24:17 +02:00
Jeroen van Rijn cdc56dc691 Add iterator for core:text/regex.
Usage:
```odin
haystack := `xxfoobarxfoobarxx`
pattern  := `f(o)ob(ar)`

it := regex.create_iterator(haystack, pattern, {.Global}) or_return
defer regex.destroy(it)

for capture in regex.match(&it) {
	fmt.println(capture)
}
```
2025-04-06 14:19:14 +02:00
gingerBill eecc6c1f18 Merge pull request #5003 from IllusionMan1212/more-android-fixes
Android bundling improvements
2025-04-06 09:28:13 +01:00
Jeroen van Rijn dbefee8905 Fix broken asan on Windows. 2025-04-05 22:01:16 +02:00
Jeroen van Rijn a6977ac733 Remove stray import. 2025-04-05 19:25:39 +02:00
Jeroen van Rijn 4b203d0c78 Fix segfault in core:sys/info on WSL2 2025-04-05 19:23:58 +02:00
Jeroen van Rijn 8d283cefa0 Merge pull request #5007 from laytan/net-errors-overhaul
net: rework errors to be cross-platform
2025-04-05 17:53:10 +02:00
Laytan Laats ff7d55a8e1 net: rework errors to be cross-platform 2025-04-05 17:35:19 +02:00
Jeroen van Rijn 6913fc2231 Merge pull request #5006 from Kelimion/fix-doc-tests
Fix broken examples in documentation tester.
2025-04-05 16:47:12 +02:00
Jeroen van Rijn f7c4c80ef3 Fix broken examples in documentation tester.
No more:
```
We could not find the procedure "pkg_foo_example :: proc()" needed to test the example created for "pkg.foo"
The following procedures were found:
   bar()
```
2025-04-05 16:36:26 +02:00
Jeroen van Rijn 8480295b60 Merge pull request #4993 from Sojamann/small-array-doc
[DOC] Add documentation for package core:container/small_array
2025-04-05 15:49:51 +02:00
Robin Bergewski e963ba12fc core:container/small_array: add package documentation 2025-04-05 15:38:42 +02:00
Hisham Aburaqibah 106427b127 fix(android): pass --sysroot when compiling the android glue code
This prevents a `function-like macro '__GLIBC_USE' is not defined`
compilation error from happening with newer NDK versions (I tried r28)
2025-04-05 15:18:27 +02:00
Hisham Aburaqibah ef49d2f0b8 print android-specific flags for the bundle command 2025-04-05 15:18:27 +02:00
IllusionMan1212 2328e84077 fix cross compilation for linux_riscv 2025-04-05 15:18:21 +02:00
Jeroen van Rijn e651803045 Merge pull request #5005 from Kelimion/fix-5004
Fix #5004
2025-04-05 14:56:10 +02:00
Jeroen van Rijn 843467bb8f Fix #5004
Fixes constant NaN to constant NaN comparisons.
2025-04-05 14:47:30 +02:00
IllusionMan1212 da885fb807 android bundling improvements
replace `jarsigner` with build tools' `apksigner` which is capable of using newer signature schemes

remove the `android-manifest` flag and assume the file exists in the directory we're bundling

make `android-keystore-alias` and `android-keystore-password` optional.
The former is not needed if there's only one key in the keystore, and the latter will be prompted by `apksigner` if missing

don't change the working directory to the bundled directory to prevent confusion when passing a relative path to
`android-keystore`

add the `res`, `assets`, and `lib` directories to the bundle if they exist in the bundled directory
2025-04-05 02:38:04 +02:00
IllusionMan1212 44950d5f37 fix: cross-compilation for android on linux
add `-nodefaultlibs` when cross-linking for android to prevent clang from linking with libgcc

check build mode first before calling `init_android_values` to prevent printing a message
that tells the user to set `-android-keystore` if its not set and build mode is exe
2025-04-05 02:20:06 +02:00
gingerBill f796b67a67 Merge pull request #5001 from justgook/master
Fix compiler build error
2025-04-04 18:35:46 +01:00
Romāns Potašovs 9557d6a644 fix compiler issue 2025-04-04 19:35:59 +03:00
gingerBill 19e056a806 Merge pull request #4997 from IllusionMan1212/android-fixes
A few fixes for android
2025-04-04 12:05:21 +01:00
dozn af0d6426c0 [core:time/timezone] Nanoseconds Not Preserved on Calls to timezone.datetime_to_tz 2025-04-04 04:01:02 -07:00
IllusionMan1212 4495f0f0f2 feat: added a -android-keystore-password option to pass a password for the keystore instead of hardcoding it as android 2025-04-04 05:23:12 +02:00
IllusionMan1212 7c26024920 fix: strip trailing slashes for android keystore and jarsigner paths
The `system()` call on linux was failing to execute the `jarsigner` command because its path had a trailing slash
2025-04-04 05:22:04 +02:00
IllusionMan1212 7d041cb2b8 fix: prevent segfault by initializing cwd to nullptr 2025-04-04 05:14:52 +02:00
gingerBill d9f990d42e Fix #4975 2025-04-03 10:55:35 +01:00
gingerBill 511c186297 Fix typo 2025-04-03 10:23:35 +01:00
gingerBill 5be052f288 Fix #4995 2025-04-03 10:20:08 +01:00
gingerBill ce5b7cccab Fix lb_add_debug_local_variable to use the correct procedure in LLVM 20 2025-04-03 10:04:14 +01:00
gingerBill 4ebaed1fdd Remove refactor 2025-04-03 09:54:44 +01:00
gingerBill e412d3b4c1 Minor clean up to lb_handle_objc_find_or_register_internal 2025-04-03 09:48:30 +01:00
gingerBill cd5bef4f61 Rewrite objc SEL/Class register handling code 2025-04-03 09:37:38 +01:00
Jeroen van Rijn d31ad3cd7f Merge pull request #4991 from nadako/sdl-3.2.10
Update vendor:sdl3 to version 3.2.10
2025-04-02 23:01:03 +02:00
Jeroen van Rijn 688540699d Merge pull request #4994 from harold-b/hb/linux-sys-built-tag
Add linux build tag to core/sys/linux/sys.odin
2025-04-02 22:46:59 +02:00
Harold Brenes c5980ba6c4 Add linux build tag to core/sys/linux/sys.odin 2025-04-02 16:39:25 -04:00
Laytan c77131dd7a Merge pull request #4992 from laytan/llvm20-releases
ci: update to LLVM 20 on MacOS and Linux CI and releases
2025-04-02 21:51:37 +02:00
Laytan 4eef57c6f1 ci: ok, had to brew update, can we now request @20 directly? 2025-04-02 21:24:12 +02:00
Laytan 85b3a79a25 ci: brew update? 2025-04-02 21:22:18 +02:00
Laytan cab3239760 ci: fix macos llvm 20 2025-04-02 21:17:45 +02:00
Laytan b0316b7076 ci: update to LLVM 20 on MacOS and Linux CI and releases 2025-04-02 21:13:10 +02:00
Dan Korostelev 4a56b25b3a Update vendor:sdl3 to version 3.2.10 2025-04-02 20:24:45 +02:00
gingerBill 5eaff20f4a Add mutex for lb_handle_objc_find_or_register_class 2025-04-02 18:26:40 +01:00
gingerBill b615e77264 Merge branch 'master' of https://github.com/odin-lang/Odin 2025-04-02 18:23:15 +01:00
gingerBill d0dd1b2d80 Add mutex for lb_handle_objc_find_or_register_selector 2025-04-02 18:23:08 +01:00
gingerBill c6b6dddccc Merge pull request #4990 from Kelimion/fix-4980
Fix #4980
2025-04-02 14:33:39 +01:00
Jeroen van Rijn 10bde20850 Fix #4980
Add nullptr check.
2025-04-02 14:21:52 +02:00
Laytan cc61fdd90e Merge pull request #4989 from SlateyDev/patch-1
Fix depth stencil not working on wgpu wasm_js build
2025-04-01 16:40:21 +02:00
Scott Campbell b0228154d9 Fix depth stencil not working on wgpu wasm_js build 2025-04-02 00:13:45 +11:00
gingerBill 70ddb74e40 Add mem.make_over_aligned 2025-03-31 10:51:02 +01:00
gingerBill dcb683927e Fix indentation 2025-03-31 10:40:03 +01:00
gingerBill 08ad2d20cd Merge pull request #4986 from hardliner66/bugfix/use_correct_size_when_resolving_symbols
Use the proper size for SizeOfStruct to make resolving of procedure names work
2025-03-30 22:28:19 +01:00
gingerBill 1a91aa0d43 Merge pull request #4984 from laytan/drop-net-darwin-os-dep
net: drop core:os dependency for Darwin
2025-03-30 22:27:46 +01:00
gingerBill 07cec670e3 Merge pull request #4982 from 4teapo/master
Use LLVM 20 in shell.nix
2025-03-30 22:27:26 +01:00
Steve Biedermann 61610fa033 Use the proper size for SizeOfStruct 2025-03-30 18:11:41 +02:00
Laytan Laats 327d9f134d net: drop core:os dependency for Darwin 2025-03-29 23:27:03 +01:00
teapo 73c3e60ce5 Use LLVM 20 in shell.nix 2025-03-28 18:38:08 +01:00
teapo a9d073e0bb Update shell.nix 2025-03-28 18:31:23 +01:00
gingerBill e7ae7b8fd4 Command package -> bundle 2025-03-28 09:27:04 +00:00
gingerBill edf97bdb03 Merge pull request #4970 from odin-lang/bill/android-subtarget
Very Very Rudimentary Support for Android
2025-03-28 09:02:26 +00:00
Jeroen van Rijn 29a8707001 Merge pull request #4978 from glektarssza/chore/fixup-detection-of-msvc
Use Microsoft "best practices" for using `vswhere`
2025-03-27 21:45:24 +01:00
G'lek Tarssza b9aa51849b Use Microsoft "best practices" for using vswhere
See https://github.com/microsoft/vswhere/wiki/Find-VC for more details.
2025-03-27 14:25:20 -06:00
gingerBill d3f0b31fcc Improve or_else type inference logic 2025-03-27 15:08:53 +00:00
gingerBill 71db9ac1ba Merge pull request #4976 from voutilad/openbsd-linker
Fix linking of programs on OpenBSD
2025-03-27 15:05:34 +00:00
Dave Voutila 5274aa53b3 Fix linker invocation on OpenBSD.
Firstly, we need to explicitly request pthreads and also need to
mind the fact ports (like SDL2) install in /usr/local/lib.

Secondly, since OpenBSD 7.4 the system enforces indirect branch
targets on hardware platforms that support it. Until the LLVM
integration in Odin can be changed to emit proper branch targets
(e.g. endbr64 on amd64), we need to request the linker make the
resulting program opt-out of enforcement.
2025-03-27 10:37:36 -04:00
Dave Voutila 18988b5f94 Fix use of errno on OpenBSD. 2025-03-27 10:36:40 -04:00
gingerBill 9b3d381af0 Fix another typo 2025-03-27 12:55:41 +00:00
gingerBill 1fc1a7fd51 Fix typos 2025-03-27 11:12:44 +00:00
gingerBill 0e6cc6ec4b Use working directory for aapt commands 2025-03-27 10:31:59 +00:00
gingerBill caac504b88 Handle android flags to be more "optional" 2025-03-27 09:53:44 +00:00
gingerBill e9fd565cfd Fix flags for odin package <platform> 2025-03-27 09:32:52 +00:00
gingerBill e29b5ae8ed Use u64 for the command kind just in case 2025-03-27 09:27:54 +00:00
gingerBill 6689c722ad odin package android 2025-03-27 09:26:33 +00:00
gingerBill 8b30adf60b Merge pull request #4973 from openhood/sys-wasm-prevent-empty-lines-in-console
Prevent odin.js from printing empty line in the console for the ending "\n"
2025-03-27 09:09:46 +00:00
gingerBill 729b6a4337 Merge pull request #4974 from harold-b/hb.fix-syscall-memory-dep
Add `~{memory}` clobber to syscall intrinsics for platforms where it was missing
2025-03-27 09:09:18 +00:00
Harold Brenes 6fda041e17 Add ~{memory} clobber to syscall intrinsics for platforms where it was not yet added.
This fixes #4972 and #4588.

As laytan asserts, there is no guarantee that a syscall will not modify memory that it just obtained from the user, or held onto via a previous syscall. Therefore this constraint should be required for all syscalls.
2025-03-26 19:25:06 -04:00
Jonathan Tron 1b5e83bfb6 Prevent odin.js from printing empty line in the console for the ending "\n" 2025-03-26 21:58:58 +01:00
gingerBill f13a075cd1 Begin work on odin package-android command 2025-03-26 18:03:36 +00:00
gingerBill 346836a098 Disable -build-mode:exe for -subtarget:android 2025-03-26 17:45:35 +00:00
gingerBill eee450516e Improve bodge for android execute build 2025-03-26 17:45:04 +00:00
gingerBill 45ecafd7b1 Really bodgy android packing system for odin build 2025-03-26 17:33:10 +00:00
gingerBill 8e884c6292 Remove _PATH on android environment variables 2025-03-26 16:50:35 +00:00
gingerBill d48e7bb0b8 Migrate ODIN_ANDROID_* constants to build_settings.cpp; -minimum-os-version:<int> for -subtarget:android 2025-03-26 16:05:21 +00:00
gingerBill db82a49576 Fix typos 2025-03-26 13:30:18 +00:00
gingerBill 518634405c Add -show-more-timings for Android stuff 2025-03-26 13:28:57 +00:00
gingerBill dfd0f18f47 Allow check for -subtarget:android 2025-03-26 13:19:40 +00:00
gingerBill e6718fcfcc Very very rudimentary support for -target:linux_arm64 -subtarget:android 2025-03-26 13:09:39 +00:00
gingerBill 4b64317296 Make things rely less on #if guards 2025-03-26 09:41:23 +00:00
Jeroen van Rijn 660598ca8a Fix #4968 2025-03-25 12:01:02 +01:00
gingerBill 5e89e5ad8b Use store 2025-03-24 13:40:24 +00:00
gingerBill fe6117fc63 Use store over memcpy 2025-03-24 13:14:54 +00:00
gingerBill ce026ff2c4 Fix #4949 2025-03-24 13:13:25 +00:00
gingerBill 56e0ab7655 Fix #4952 2025-03-24 13:11:41 +00:00
gingerBill acb578f184 Fix #4962 2025-03-24 11:35:10 +00:00
gingerBill 2b8c76354d Use copy over intrinsics.mem_copy_non_overlapping 2025-03-24 11:31:05 +00:00
gingerBill 4a595f9dac Merge pull request #4954 from Feoramund/os2-path
Add new path API for `os2`
2025-03-24 11:19:21 +00:00
gingerBill 6fd752f647 Merge pull request #4959 from wisonye/master
Fixed: Freebsd syscall 'getpeername' is missing.
2025-03-24 10:10:15 +00:00
gingerBill 3d9a8baba8 Merge pull request #4965 from dogue/master
`vendor:x11/xlib`: add proc binding for SetWindowBorder
2025-03-24 10:09:58 +00:00
dogue 87db5f2df4 xlib: add proc binding for SetWindowBorder 2025-03-23 22:09:42 -04:00
Laytan 2e64f5f639 Merge pull request #4960 from jimhub/wgpu-js-fixes
Bug fixes for wgpu.js
2025-03-23 17:01:49 +01:00
Jeroen van Rijn 242f59a43d Merge pull request #4124 from Yawning/feature/crypto
core/crypto: More improvements
2025-03-23 11:38:11 +01:00
Yawning Angel 38665431dd core/crypto/_aes/ct64: Disable bounds checking 2025-03-23 19:17:18 +09:00
Yawning Angel 2f301e46dc core/crypto: Switch to using ensure 2025-03-23 19:14:33 +09:00
Yawning Angel dc94452fb9 core/crypto/blake2: Add the ability to easily alter digest size 2025-03-23 19:14:33 +09:00
Yawning Angel 93951ac72a core/crypto/sha2: Clean up the portable code slightly 2025-03-23 19:14:33 +09:00
Yawning Angel 982ab11aa1 core/crypto/sha2: Use hardware SHA224/256 when available (AMD64) 2025-03-23 19:14:33 +09:00
Yawning Angel f3f5fbd373 test/benchmarks/crypto: Improve benchmarks
- Use text/table for results
- Add more benchmarks
2025-03-23 19:14:33 +09:00
Yawning Angel b220df60b8 core:crypto/deoxysii: Initial import 2025-03-23 19:14:33 +09:00
Yawning Angel c2786a6dd5 core/crypto/aegis: Initial import 2025-03-23 19:14:33 +09:00
Yawning Angel 9fdcc4e39a core/crypto/x448: Initial import 2025-03-23 19:14:33 +09:00
Yawning Angel bb395aeb41 core/crypto: Add rodata annotations (NFC) 2025-03-23 19:14:33 +09:00
Yawning Angel 50d40c2a26 core/crypto/chacha20poly1305: Add missing assertions 2025-03-23 19:14:33 +09:00
Yawning Angel 6e8710fce4 core/crypto/chacha20: Misc Simd128 improvements
- Detect the RISC-V `v` profile
- Don't bother trying to process 4 blocks at a time if emulated
2025-03-23 19:14:33 +09:00
Yawning Angel e4e76f27f6 core/crypto: Use panic_contextless instead of intrinsics.trap 2025-03-23 19:14:33 +09:00
Yawning Angel 4c28f6d170 core/crypto/_aes/hw_intel: Fix comment (NFC) 2025-03-23 19:14:33 +09:00
James Liljenquist 0113907527 Bug fixes for wgpu.js 2025-03-22 21:01:15 -06:00
Wison Ye 61acb15529 #4959, fixed the broken CI build. 2025-03-23 13:32:11 +13:00
Wison Ye 2af691f587 Fixed: Freebsd syscall 'getpeername' is missing. 2025-03-23 13:22:19 +13:00
ed 36ac7e1da1 Merge remote-tracking branch 'offical/master' 2025-03-22 13:37:59 -04:00
Jeroen van Rijn f578ce3acb Merge pull request #4957 from Barinzaya/fix-mem-make_map
Fix `mem.make_map`
2025-03-22 16:34:32 +01:00
Barinzaya 7819797a03 Split mem.make_map to match the runtime procs.
The existing `mem.make_map` passes a capacity, but the builtin
`make_map` no longer takes a capacity--it was separated to
`make_map_cap` to allow for making a map without an allocation (#4340).

`core:mem` was not updated to reflect this, so any usage of `mem.make`
to make a map will currently result in a compile error.
2025-03-22 11:03:04 -04:00
Laytan 7ffbb68fff Merge pull request #4955 from wisonye/master
Fixed #4892: 'EPoll_Event.events' should be bit set.
2025-03-22 12:59:32 +01:00
Wison Ye 17a01dcebf Merge remote-tracking branch 'upstream/master' 2025-03-22 17:52:43 +13:00
Wison Ye 01e81fe597 Fixed #4892: 'EPoll_Event.events' should be bit set. 2025-03-22 17:51:08 +13:00
Laytan Laats e4bc9677af fix unmarshalling bit sets in json
Fixes #4761
2025-03-22 00:20:00 +01: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
Laytan Laats cf0f73e0cf fix typo for freebsd arm64 MINSIGSTKSZ
Fixes #4878
2025-03-21 23:52:52 +01:00
Laytan Laats 73fd564634 fix tabs 2025-03-21 23:02:00 +01:00
Laytan Laats f85db012b8 fix off by one temp cstring and put objc names on permanent allocator to be safe
Fixes #4922
2025-03-21 22:56:19 +01:00
gingerBill 69b969ef7f Merge pull request #4953 from openhood/wasm-prevent-duplicate-event-listeners
Prevent registering the same event listener twice on the same element with the exact same data in wasm.
2025-03-21 21:34:03 +00:00
Laytan Laats 057144dea3 fix linux release trying to use non-existant llvm 20 package 2025-03-21 21:47:40 +01:00
Jonathan Tron 2bccd07426 Prevent registering the same event listener twice on the same element with the exact same data in wasm. 2025-03-21 09:38:23 +01:00
Feoramund d1d86234aa Add missing documentation to os2/path 2025-03-20 18:36:26 -04:00
gingerBill 631406eecc Merge pull request #4951 from openhood/wasm-fix-remove-event-listeners
Fix add/remove event listeners in `core:sys/wasm`
2025-03-20 21:31:38 +00: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
gingerBill 539e9bd2e3 Merge pull request #4836 from laytan/fix-wrong-out-of-memory
fix wrong out of memory in edge cases, just try allocate from block for one source of truth
2025-03-20 17:20:26 +00:00
Laytan Laats badd2c90f9 drop llvm 19 feature/microarch table
There was a bug in LLVM 19 introduced in https://github.com/llvm/llvm-project/pull/96249 and fixed in https://github.com/llvm/llvm-project/pull/118581.

Lets just use the LLVM 18 table for LLVM 19.
2025-03-20 16:51:27 +01:00
Jonathan Tron dbe53d053a Fix add/remove event listeners in core:sys/wasm
There were multiple issues here:

1. listeners stored in the same key overwriting the previous one
2. missing `use_capture` parameter in `remove_event_listener`/`remove_window_event_listener`

The key used to store the listener function in `listenerMap` was a
javascript `Object`, when used as a key it was thus serialized to
the string `"[object Object]"`, meaning all listeners where effectively
set to the same key when calling `add_event_listener`/`add_window_event_listener`.
Later on when calling `remove_event_listener`/`remove_window_event_listener`,
it then tried to remove the incorrect one or none at all if there was a
mix of the same event name registered on an element or the window.

To fix I implemented a function `listener_key` in the javascript code
which will generate a different key based on the event's:
- `id`: dom element's id or 'window' (when event listener added to the
  window)
- `name`: the event name (eg: `click`), each event handler should be
  removed for the event name it was register on.
- `data`: we can register events with different data, each one generate
  a new listener which has to be removed.
- `callback`: same as `data`, if you register two similar handler but
  with two different callback, each one should be removed.
- `useCapture`: this one is a bit tricky, but when you register an event
  handler in javascript, if you don't pass `useCapture`, it defaults to `false`.
  When you remove an handler, you have to pass the exact same
  `useCapture` option you registered it with. In this case, we allowed
  to register an event with different `useCapture`, but didn't allow to
  pass the `useCapture` when removing it. We always called `removeEventListener`
  without the `useCapture` parameter which removed the handler properly
  only when it was registered with `useCapture=false`.

I also switched the `WasmMemoryInterface.listenerMap` from `{}`
(javascript object) to a `new Map()`, which is available everywhere
nowadays.
2025-03-20 16:43:49 +01:00
gingerBill 0f01b34b38 Merge pull request #4948 from laytan/llvm-20-plus
few llvm 20 changes
2025-03-19 23:19:17 +00:00
Laytan Laats f80e73e036 few llvm 20 changes 2025-03-19 21:22:55 +01:00
gingerBill 067442ee32 Merge pull request #4945 from odin-lang/llvm-20
Update to LLVM 20.1.0
2025-03-19 10:16:31 +00:00
gingerBill 8e84933fe9 Use 18 for RISCV64 2025-03-19 09:23:15 +00:00
gingerBill f13fc27ae0 Use LLVM-18 on FreeBSD 2025-03-18 16:53:10 +00:00
gingerBill de14aa510b Use LLVM-18 on macOS Intel 2025-03-18 16:46:54 +00:00
gingerBill 809ee42873 Fix typo in passes 2025-03-18 16:46:15 +00:00
gingerBill f2b962a492 Use LLVM-18 for macOS ARM 2025-03-18 16:41:25 +00:00
gingerBill b2376d05a6 Fix typo 2025-03-18 16:39:08 +00:00
gingerBill cf982fc222 Update to LLVM 20 in CI. 2025-03-18 16:35:55 +00:00
gingerBill 4c3c3a0631 Add new LLVM 20 passes 2025-03-18 16:21:08 +00:00
gingerBill d209af5094 Update to LLVM 20.1.0 2025-03-18 15:39:18 +00:00
dozn 3148acf6a6 [core:encoding/json] When Unmarshalling, Only Match Struct Tags If Present 2025-03-17 01:51:04 -07:00
gingerBill 0c70ec0330 Merge pull request #4934 from laytan/vendor-libc-additions
vendor/libc: a bunch of additions
2025-03-13 09:23:20 +00:00
gingerBill 408b3af550 Merge pull request #4933 from laytan/js-open-binding
core/sys/wasm/js: add `open` binding to `window.open`
2025-03-13 09:22:20 +00:00
gingerBill 35340de928 Merge pull request #4932 from laytan/js-pointer-event-and-charcode
core/sys/wasm/js: add pointer event info and add charCode to keyboard
2025-03-13 09:22:03 +00:00
gingerBill 5a12190f51 Merge pull request #4931 from laytan/webgl-improvements
webgl: add `BlendEquationSeparate` and `GetParameter4i`
2025-03-13 09:21:44 +00:00
gingerBill 9b7aebe2b6 Merge pull request #4930 from laytan/js-gamepad-improvements
core/sys/wasm/js: improve gamepad API
2025-03-13 09:21:15 +00:00
Laytan Laats 140c902eff vendor/libc: a bunch of additions
All these additions are to allow Dear ImGui to be compiled natively.
2025-03-12 19:25:35 +01:00
Laytan Laats 6691acfa03 core/sys/wasm/js: add open binding to window.open 2025-03-12 18:43:03 +01:00
Laytan Laats b76fd84084 webgl: add BlendEquationSeparate and GetParameter4i
`GetParameter4i` can be used to retrieve the current scissor rect, or
the curent viewport, which was previously impossible.

Also adds `BlendEquationSeparate` which seemed to be missing.

Also removes an instance of `do`.
2025-03-12 18:39:57 +01:00
Laytan Laats 00ac48c06c core/sys/wasm/js: add pointer event info and add charCode to keyboard events 2025-03-12 18:37:42 +01:00
Laytan Laats d349c96071 core/sys/wasm/js: improve gamepad API
1. Properly set `id` and `mapping` on the `get_gamepad_state` result
2. Increase `id` limit to 96 bytes, connecting my DualShock 4 made it crash
3. If an `id` or `mapping` is longer than the limits, slice it and add `...`
2025-03-12 18:32:51 +01:00
gingerBill d3b1aaad18 Use :: rather than $ to try and fix mac SEL stuff 2025-03-12 12:53:26 +00:00
gingerBill d5fe392edd Merge pull request #4927 from voutilad/openbsd-futex
Fix futex(2) usage on OpenBSD.
2025-03-11 15:51:57 +00:00
gingerBill d15be94a0f Remove debug print 2025-03-11 15:50:46 +00:00
gingerBill 6e1c21411d Fix object name generation 2025-03-11 15:50:31 +00:00
gingerBill ffef302543 Merge pull request #4925 from jasonKercher/fix-sigaction
Fix linux.rt_sigaction
2025-03-11 15:45:16 +00:00
Dave Voutila 0059507374 Fix futex(8) usage on OpenBSD. 2025-03-11 10:28:48 -04:00
jason ae02ced175 Fix linux.rt_sigaction
Add missing polymorphic parameter to Sig_Action
2025-03-10 20:27:59 -04:00
gingerBill 1035f0839d Merge pull request #4915 from chuga-git/sdl3-get-pixel-format-name
vendor/sdl3: fix GetPixelFormatName() returning rawptr instead of cstring
2025-03-10 17:29:46 +00:00
gingerBill 6837e23e73 Merge pull request #4919 from latedeployment/add-linux-syscalls
Add missing x86 syscalls from map_shadow_stack to removexattrat
2025-03-10 17:29:32 +00:00
Jeroen van Rijn a91d528af6 Merge pull request #4921 from cornishon/fmt_allocator_docs
Update `fmt` docs for procedures with a default allocator parameter
2025-03-09 14:14:18 +01:00
Adam Zadrożny 7866f7ab2b Update fmt docs for procedures with a default allocator parameter 2025-03-09 13:35:12 +01:00
latedeployment 0491ad55f4 Add missing syscalls from map_shadow_stack to removexattrat 2025-03-07 21:54:51 +02:00
gingerBill d011cb871e Remove .wasm from CI 2025-03-07 11:18:19 +00:00
gingerBill 7f61e53286 Fix #3955 2025-03-07 10:48:49 +00:00
gingerBill 97eeb25adc Fix #4244 2025-03-07 10:44:34 +00:00
gingerBill af37ca1286 Fix #4573 2025-03-07 10:38:36 +00:00
gingerBill 168a41ba2c Fix #4803 2025-03-07 10:33:41 +00:00
gingerBill f3210eccaf Fix #4866 2025-03-07 09:44:18 +00:00
chuga eca08929cd vendor/sdl3: changed GetPixelFormatName() return type from rawptr to cstring 2025-03-07 00:33:44 -06:00
gingerBill 97d410c2ae Fix #4909 2025-03-06 11:17:55 +00:00
gingerBill 51d799d2ea Merge branch 'master' of https://github.com/odin-lang/Odin 2025-03-06 11:15:33 +00:00
gingerBill 55317b0987 Fix #4914 2025-03-06 11:15:27 +00:00
Jeroen van Rijn 874efa5fe8 Merge pull request #4912 from flysand7/remove-epoch-datetime
[datetime]: Remove the definition of EPOCH
2025-03-06 12:10:48 +01:00
ed 482e17c9a4 Merge remote-tracking branch 'offical/master' 2025-03-06 05:27:42 -05:00
gingerBill fcee19434e Fix object name generation to previous behaviour 2025-03-06 09:49:30 +00:00
flysand7 47eefb3f21 [datetime]: Remove the definition of EPOCH 2025-03-06 20:28:12 +11:00
Laytan 7d26edb83c Merge pull request #4910 from Feoramund/fix-strings-clone-2x-slice
Remove unneeded slicing in `strings.clone`
2025-03-05 20:15:30 +01:00
Feoramund fef5f526f3 Remove unneeded slicing in strings.clone 2025-03-05 13:54:31 -05:00
gingerBill 951bef4ade Merge pull request #4907 from Feoramund/os2-fix-env-linux
Fix data races in `os2/env_linux.odin`
2025-03-05 13:03:07 +00: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
gingerBill 69b6c59ea6 Merge pull request #4905 from Feoramund/os2-fix-random-string
Use `context.random_generator` for `os2.random_string`
2025-03-04 07:51:33 +00:00
gingerBill 8214892b5b Merge pull request #4893 from Barinzaya/for-bitset-ctz
Use CTZ in `for in bit_set` codegen
2025-03-04 07:51:09 +00: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
Laytan Laats 71eb26ef15 wgpu: fix link in doc.odin 2025-03-03 22:18:44 +01:00
Laytan Laats 52dd651aed wgpu: device lost callback device by pointer in JS 2025-03-03 22:15:35 +01:00
Laytan 19d176c2c7 Merge pull request #4899 from Valakor/wgpu
wgpu: Some small fixes after update to v24.0.0.2
2025-03-03 21:58:27 +01:00
Laytan 2dbf8d0f37 Merge pull request #4904 from laytan/move-wgpu-examples-to-examples-repo
wgpu: move examples to examples repo
2025-03-03 21:30:23 +01:00
Laytan Laats 7fc55eb92a wgpu: move examples to examples repo 2025-03-03 21:22:59 +01:00
Laytan Laats 189b4782fb dynlib: fix initialize_symbols when there is no field for the handle in the struct 2025-03-03 20:33:33 +01:00
Laytan Laats 05add96fc8 sys/windows: fix tabs 2025-03-03 19:30:22 +01:00
gingerBill 21a6648cde Fix #4903 2025-03-03 15:16:50 +00:00
gingerBill 4170e6e6d4 Merge pull request #4900 from Barinzaya/fix-bitset-xor-changes-enum
Fix `~bit_set[Some_Enum]` altering the enum
2025-03-03 11:03:17 +00:00
gingerBill a71156699a Merge pull request #4901 from Feoramund/os2-fixes
Fix a couple bugs in `os2`
2025-03-03 11:02:23 +00: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
Barinzaya ef83f2115a Implemented #reverse for for in bit_set. 2025-03-02 16:24:18 -05:00
Matthew Pohlmann 397de28580 Fix typo: SprivShaderPassThrough -> SpirvShaderPassthrough 2025-03-02 11:13:41 -08:00
Barinzaya 6e3d17d189 Fixed ~ on bit_set[Some_Enum] altering the definition of the enum.
This was occurring for enums whose minimum values were greater than
zero.
2025-03-02 13:29:39 -05:00
Matthew Pohlmann af897ba689 Some more fixes: ChainedStruct vs. ChainedStructOut, desiredMaximumFrameLatency, and 'const' annotations 2025-03-02 10:18:36 -08:00
Matthew Pohlmann eadbf5ebb1 Merge branch 'wgpu' of https://github.com/Valakor/Odin into wgpu 2025-03-02 09:34:48 -08:00
Matthew Pohlmann 440c52fd53 Use ^Device instead of Maybe(Device) for device callbacks 2025-03-02 09:34:43 -08:00
Matthew Pohlmann 719e973638 Merge branch 'odin-lang:master' into wgpu 2025-03-02 09:17:15 -08:00
Matthew Pohlmann be3f523358 wgpu v24.0.0.2 fixes 2025-03-02 09:16:40 -08:00
gingerBill 4b2b49dc30 Merge pull request #4898 from alektron/ArenaTotalUsedMismatch
Invalid virtual arena state after resize
2025-03-02 17:15:52 +00:00
alektron fd539b5e81 Fix: When resizing a virtual arena by commiting more of the already reserved memory, the total_used field of the arena was not updated; 2025-03-02 17:46:39 +01:00
Courtney Strachan dbbe96ae5c Fixed json null value parsing 2025-03-02 07:57:23 -08:00
gingerBill b9b27bc1e0 Merge pull request #4853 from laytan/update-wgpu-24
wgpu: update to v24.0.0.2
2025-03-02 15:12:23 +00:00
Jeroen van Rijn 7841d0b14b Merge pull request #4884 from Dzentsetsu/master
Add DWM_WINDOW_CORNER_PREFERENCE enum for window corner preferences
2025-03-02 13:50:00 +01:00
gingerBill 3963ad1cc1 Update core/sys/windows/dwmapi.odin
Co-authored-by: Laytan <laytanlaats@hotmail.com>
2025-03-02 12:24:45 +00:00
gingerBill dc1d49f353 Merge pull request #4545 from flysand7/docs-simd
[core/simd]: Write package documentation
2025-03-02 12:24:01 +00:00
gingerBill 5800ac63a6 Merge pull request #4886 from hypno2000/vulkan-bindings
vulkan bindings update with bit_set/bit_field handling changes
2025-03-02 12:22:26 +00:00
flysand7 70daf40cb1 Fix documentation for simd_shuffle 2025-03-02 20:42:13 +11:00
flysand7 698c510ba7 Merge branch 'master' into docs-simd 2025-03-02 20:05:55 +11:00
gingerBill f390598b40 Merge pull request #4894 from 0xafbf/sdl3_image
Add support for SDL3_image.
2025-03-01 17:12:06 +00:00
Andrés Botero 1853886a26 Prefer using an absolute reference for SDL3 2025-03-01 10:44:47 -05:00
gingerBill ee84487106 Merge branch 'master' of https://github.com/odin-lang/Odin 2025-03-01 15:19:51 +00:00
gingerBill 211680569f Fix for -use-single-module 2025-03-01 15:19:46 +00:00
Laytan Laats 66540b75f5 fix hidden linkage applied to foreign symbols 2025-03-01 16:06:32 +01:00
Andrés Botero 1910de54ab Add support for SDL3_image. 2025-03-01 08:44:05 -05:00
Laytan bb20b03f2e Merge pull request #4887 from Skytrias/skytrias-orca-ui-update
Update to newest orca bindings (UI Update)
2025-03-01 13:58:55 +01:00
Michael Kutowski 57a1264450 proper enums 2025-03-01 13:33:23 +01:00
Reio Piller 4a04fa2c78 fix ident 2025-03-01 02:23:38 +02:00
Laytan Laats 76bf7875f5 wgpu: update to v24.0.0.2 2025-02-28 18:38:51 +01:00
gingerBill bb429696f8 Merge pull request #4877 from laytan/os2-additions
os/os2: recursive directory walker, expose errors in read_directory, file clone
2025-02-28 14:37:47 +00:00
gingerBill 8a8894a981 Merge pull request #4891 from Feoramund/fix-4890
Fix #4890
2025-02-28 14:08:27 +00:00
gingerBill 79944056b9 Add Error to os2.set_env 2025-02-28 13:52:51 +00:00
gingerBill b3bbb00f1a Add Error as part of the return values of os2.environ 2025-02-28 13:43:50 +00:00
Barinzaya 36d5e09419 Re-implemented for on bit_sets to use CTZ.
This solution is both faster at run-time and a simpler implementation
than the original solution, which required separate cases for enums and
ranges.
2025-02-28 06:51:14 -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
Reio Piller 75f11691b0 cube 2025-02-28 01:33:10 +02:00
Laytan Laats 94152ca701 misc/featuregen: fix script 2025-02-27 22:45:34 +01:00
Laytan Laats a9d4cb96b0 wgpu: stringView -> StringView typo 2025-02-27 22:29:51 +01:00
Laytan Laats 1223b3e260 wgpu: fix mode which is u64 not unwrapping big int 2025-02-27 22:29:32 +01:00
Laytan Laats b6f34332fe wgpu: copy over gpu contents to cpu side when mapping 2025-02-27 22:28:49 +01:00
Laytan Laats 19b70f5ef7 wgpu: layout left blank should set it to "auto" in JS 2025-02-27 22:28:15 +01:00
Laytan Laats 1942a538d8 wgpu: fix wrapper and add more wrappers 2025-02-27 18:39:29 +01:00
Laytan Laats 1cb28f7f73 wgpu: remove mode field of uncaptured error callback info 2025-02-27 18:31:32 +01:00
Laytan Laats 30f65372de wgpu: add missing libs on Windows 2025-02-27 18:27:31 +01:00
Reio Piller 81a71cc314 add vulkan vulkan_beta.h bindings 2025-02-27 17:32:36 +02:00
Michael Kutowski 43c54d4de8 Update to newest orca bindings (UI Update), remove logging due to cyclic import (fmt usage) 2025-02-26 23:03:44 +01:00
Reio Piller 942f990e50 bit_field type fix 2025-02-26 23:19:53 +02:00
Reio Piller 5a0a8e9026 vulkan bindings update with bit_set/bit_field handling changes 2025-02-26 22:57:39 +02:00
gingerBill 882186f4da Merge pull request #4883 from Githubaccountlol/master
Correct core/mem/doc.odin
2025-02-26 09:50:44 +00:00
Roman Osipov a1597022af Add DWM_WINDOW_CORNER_PREFERENCE enum for window corner preferences 2025-02-26 12:23:49 +03:00
Githubaccountlol 88f423a38b Update doc.odin 2025-02-26 03:04:54 -06:00
gingerBill 1f6ddc0f36 Merge pull request #4881 from sndb/sdl-nil-rect
SDL3: Replace `#by_ptr ...` with `Maybe(^...)` where API allows nil pointers to rects
2025-02-26 08:58:49 +00:00
sndb 5fc1984fd4 Replace #by_ptr ... with Maybe(^...) where SDL API allows nil pointers 2025-02-26 09:54:39 +03:00
gingerBill cae91c9472 Fix rune printing with %b 2025-02-25 15:53:06 +00:00
gingerBill 400348c925 Improve global array index to be on a per module basis 2025-02-25 15:06:13 +00:00
gingerBill 92f6d2745b Make lb_add_global_generated_from_procedure not use a global index but local to procedure 2025-02-25 15:01:12 +00:00
gingerBill 46c0910a77 Fix lb_add_global_generated_with_name 2025-02-25 14:59:59 +00:00
gingerBill fd6d7d412d Use more predictable object name 2025-02-25 14:55:33 +00:00
gingerBill 5aafbc7f30 Use more deterministic module names 2025-02-25 14:35:54 +00:00
gingerBill f9d85a7311 Try to make globally generated variables deterministic in name 2025-02-25 14:29:14 +00:00
Laytan Laats 22ab8935c4 slice: use card in bitset_to_enum_slice_with_make
Fixes #4870
2025-02-24 21:10:12 +01:00
Laytan Laats 77c7087de3 wgpu: update release 2025-02-24 20:52:14 +01:00
Laytan Laats 0e4140a602 os/os2: recursive directory walker, expose errors in read_directory, file clone
Adds a directory walker, a method of exposing and retrieving errors from
the existing read directory iterator, allows reusing of the existing
read directory iterator, and adds a file clone procedure
2025-02-24 20:40:44 +01:00
gingerBill faaa05536f Support -show-timings for odin doc 2025-02-24 17:42:21 +00:00
gingerBill d0d5cf800e Fix nullptr check 2025-02-24 15:49:49 +00:00
gingerBill 344eb6cb42 Fix name canonicalization for doc writer 2025-02-24 15:44:38 +00:00
gingerBill f56a0a80d3 Use type hash for doc writer 2025-02-24 15:37:54 +00:00
gingerBill de70e6faa0 Use more type hashes where possible 2025-02-24 15:33:35 +00:00
gingerBill 83f1c879ec Canonicalize generated procedures (hasher/equal/map) 2025-02-24 15:18:27 +00:00
gingerBill 68731b2b50 Canonicalize global source code locations 2025-02-24 14:36:19 +00:00
gingerBill 2c86fadee1 More name canonicalization for globals 2025-02-24 14:28:24 +00:00
gingerBill f0f395c510 Fix canonicalization 2025-02-24 14:24:06 +00:00
gingerBill 46a8991d0f Canonicalize generated procedures 2025-02-24 14:19:02 +00:00
gingerBill 533f82da24 Fix #4822 2025-02-24 14:11:47 +00:00
gingerBill c2cafcbe14 Fix #4819 2025-02-24 14:07:39 +00:00
gingerBill 0781526b35 Merge pull request #4466 from Barinzaya/simd_extract_msbs
SIMD Extract MSbs/LSbs Intrinsics
2025-02-24 14:04:07 +00:00
Barinzaya 4afedbc051 Added simd_extract_lsbs intrinsic as well.
Equivalent to the simd_extract_msbs intrinsic, except it extracts the
least significant bit of each element instead.
2025-02-24 08:49:57 -05:00
gingerBill ef016d957b Add @(require_results) to random generator 2025-02-24 13:48:07 +00:00
gingerBill c45f39702a stdcall to system 2025-02-24 13:45:50 +00:00
gingerBill e25507ca3b Merge pull request #2938 from moritzfalk/d3d11-annotations
Adding IUserDefinedAnnotation to D3D11 for better debugging.
2025-02-24 13:39:58 +00:00
Barinzaya 33a3aab791 Added simd_extract_msbs intrinsic. 2025-02-24 08:39:32 -05:00
gingerBill d23453811d Improve semicolon checking rules when parsing 2025-02-24 13:13:36 +00:00
gingerBill c0b923c1c6 Merge pull request #4874 from keenanwoodall/ns-save-panel-url-not-array
Darwin/Foundation `SavePanel_URL` returns ^URL instead of ^Array
2025-02-24 08:23:41 +00:00
Keenan Woodall a709876788 SavePanel_URL returns ^URL instead of ^Array 2025-02-23 19:00:27 -06:00
Jeroen van Rijn b6e4765e63 Merge pull request #4872 from haesbaert/dns-spoof
Fix multiple vulnerabilities in the resolver
2025-02-23 19:13:21 +01:00
Christiano Haesbaert 42d7e7a402 Fix multiple vulnerabilities in the resolver
This fixes some vulnerabilities in the resolver that make spoofing DNS
queries somewhat trivial due to the code failing to randomize xid, as
well as match the reply xid with the query, and the origin of the packet:

 - xid of the query was fixed at zero
 - xid from the reply was never checked
 - source address of the reply was never checked

This means anyone can flood the host with a fake reply with xid 0,
guessing the source port is trivial as it's less than 16bits (2^16 -
1024), which would cause odin to resolve a hostname to whatever an
attacker wanted.

While here also plug in two memory leaks.

Since this is CVE material, I've contacted @kelimion before hand which
instructed to put it in a PR.

There are also more bugs as the code conflates answer section,
authority section and aditional section into one, while in reality
only the anwer section should be taken into consideration.
2025-02-23 17:28:32 +01:00
Jeroen van Rijn 940da61869 Fix missing error when TCP connection refused.
Fixes #4867
2025-02-23 12:47:22 +01:00
gingerBill ebda946d61 Move temporary array out of CheckerInfo 2025-02-22 18:12:43 +00:00
gingerBill de755f95ec Minor rearrange for parsing field lists 2025-02-22 17:58:14 +00:00
gingerBill 875dbf3140 Disallow syntax: proc(x,:T) 2025-02-22 17:56:42 +00:00
gingerBill 5bd43b94ec Improve error message for matrices with no rows or columns 2025-02-22 17:50:37 +00:00
gingerBill 748a771dad Allow indirection for swizzling on procedure parameters 2025-02-21 12:38:40 +00:00
gingerBill 55e0f945a1 Merge pull request #4860 from odin-lang/bill/typeid_hash_table
Change `typeid` definition to be based around the canonical type hash
2025-02-21 10:21:28 +00:00
gingerBill 7e58f0a279 Merge pull request #4861 from Barinzaya/simdvec_equality_fix
SIMD Vector Equality Fix
2025-02-21 09:33:00 +00:00
Barinzaya 266e84103e Fixed an issue with SIMD vector equality.
Comparing SIMD vectors with `==` was checking that the mask of elements
that matched was not 0, meaning it succeeded if *any* element was equal,
rather than if *all* elements were equal.
2025-02-20 17:05:07 -05:00
gingerBill bf9f2e43bf Fix typeid size in LLVM 2025-02-20 18:47:41 +00:00
gingerBill e8c38e7427 Handle any correctly for 32-bit systems 2025-02-20 17:50:56 +00:00
gingerBill 614c0dd740 Fix typeid size for 32-bit platforms 2025-02-20 17:10:04 +00:00
gingerBill 4ece0617bc Keep -vet happy 2025-02-20 14:18:19 +00:00
gingerBill 5489a88983 Change typeid definition to be based around the canonical type hash
`typeid` used to be a fancy index with extra metadata stored on it. Now it is direct hash of the type.

This is safe to do in practice since any possible collisions are checked at compile time AND the chances of having a 1% collision are around 1 in 600K (see the Birthday Paradox).

Therefore accessing a `^Type_Info` is now a hash table lookup with linear probing. The table is twice the size than necessary so prevent too much probing due to an overly dense hash table.
2025-02-20 14:10:45 +00:00
gingerBill c25ac939d4 Add cast back 2025-02-20 13:27:18 +00:00
gingerBill 1d348318f2 Use PtrMap temporarily 2025-02-20 13:23:23 +00:00
gingerBill 0ab323012e Use TypeSet instead of PtrSet<Type *> 2025-02-20 11:12:59 +00:00
gingerBill 0946f6b48b Improve name canonicalization for some debuggers 2025-02-20 11:11:22 +00:00
gingerBill 90a973ccf6 Make debug symbols use the new name canonicalization rules 2025-02-20 10:27:59 +00:00
gingerBill 9dc4d5a4e6 Merge pull request #4845 from Barinzaya/fmt_variable_wp_without_index
Variable Width/Precision Without Index in `fmt`
2025-02-20 08:49:48 +00:00
gingerBill 82ddf358d0 Merge pull request #4855 from odin-lang/bill/canonical-type-hashing
Deterministic Canonical Naming for Link Names and Types
2025-02-20 08:47:48 +00:00
gingerBill 29456bcdea Move docs to the header 2025-02-19 11:12:32 +00:00
gingerBill 0bac34eec8 Number fields within procedures with a depth-first numbering system 2025-02-19 10:59:05 +00:00
Laytan Laats cae3f13d9f mem/virtual: specify max protection on mmap call in NetBSD and FreeBSD 2025-02-18 18:33:19 +01:00
gingerBill 827cd45f04 Add to check to fix crash 2025-02-18 17:12:58 +00:00
gingerBill 0482facdda Fix for weird builtin types 2025-02-18 15:26:59 +00:00
gingerBill e168cea670 Add offset for nested things 2025-02-18 15:17:04 +00:00
gingerBill 481745784f Remove debug print 2025-02-18 15:04:02 +00:00
gingerBill 04c1ff61f4 Update the comments 2025-02-18 15:03:49 +00:00
gingerBill 575a8ae510 Merge branch 'bill/canonical-type-hashing' of https://github.com/odin-lang/Odin into bill/canonical-type-hashing 2025-02-18 14:33:31 +00:00
gingerBill 23efd1bd02 Add TypeWriter stream to allow for in-place hashing and string generation 2025-02-18 14:32:41 +00:00
gingerBill cc90e0cbbf Add TypeWriter stream to allow for in-place hashing and string generation 2025-02-18 14:21:40 +00:00
gingerBill 19b59461b0 Use TypeSet for DeclInfo deps 2025-02-18 13:31:34 +00:00
gingerBill 721bcf2249 Minor code clean up 2025-02-18 13:24:08 +00:00
gingerBill d69eb57cfa Fix typos 2025-02-18 13:18:51 +00:00
Laytan Laats ae9388c013 wgpu: update to v24.0.0 2025-02-17 19:55:44 +01:00
gingerBill 4a29d9bb84 Simplify type info table construction 2025-02-17 16:29:42 +00:00
gingerBill b8f057951c Begin work on TypeSet 2025-02-17 13:46:17 +00:00
gingerBill 9b26bb2e6a Begin work on hash types 2025-02-17 13:10:38 +00:00
gingerBill 043f9aea61 Clean up rules for name mangling 2025-02-17 12:40:43 +00:00
gingerBill b5cf776830 Use new name canonicalization approach 2025-02-17 11:48:54 +00:00
gingerBill 99d91ccd31 Work on making name mangling deterministic 2025-02-17 11:32:49 +00:00
gingerBill 4eba3698aa Begin work on nested declarations 2025-02-17 09:47:49 +00:00
Laytan f0b1357132 Merge pull request #4848 from dozn/master
[core:flags] Add Missing `allocator` and `loc` Params on Call to `parse()`
2025-02-15 18:02:19 +01:00
dozn b99aee65bf Pass in allocator and loc to core:flags.parse() 2025-02-15 08:47:08 -08:00
gingerBill 2a5933513c Fill in more canonical types 2025-02-15 12:32:05 +00:00
gingerBill 98201962e0 Begin work on producing a canonicalized type string for hashing types. 2025-02-14 17:29:38 +00:00
Barinzaya dc2c9b5d51 Support use of * in format strings without an index.
This allows `*` to be used in C fashion, without specifying an argument
index to use. Like C, this results in the argument *preceding* the value
for the format specifier itself.
2025-02-14 10:44:42 -05:00
gingerBill 04830e944b Merge pull request #4844 from Gabr1313/master
Fix typos
2025-02-14 15:01:24 +00:00
Gabr1313 2c7ec27445 Fix typos 2025-02-14 14:38:26 +01:00
ed 37f692fd74 Merge remote-tracking branch 'offical/master' 2025-02-13 15:43:19 -05:00
gingerBill 816566d8aa Merge pull request #4837 from SlashScreen/sdl3_glue
wgpu: add sdl3 glue
2025-02-13 12:32:09 +00:00
Slashscreen b7f37bbee5 removed cast. 2025-02-12 16:13:57 -08:00
Slashscreen 503813431b Switched X11 and Wayland 2025-02-12 15:58:56 -08:00
Slashscreen 2f82d4e325 fixed many oversights 2025-02-12 15:06:22 -08:00
Slashscreen 02b19b115b wgpu: add sdl3 glue 2025-02-12 14:27:16 -08:00
Laytan Laats 435f77b16b fix space indentations 2025-02-12 19:33:41 +01:00
Laytan Laats 55302280d8 fix addrinfo struct def
Fixes #4816
2025-02-12 19:24:27 +01:00
Laytan Laats ae0f69fbe2 cleanup test arenas 2025-02-12 19:13:16 +01:00
Laytan Laats 7df5be2131 fix wrong out of memory in edge cases, just try allocate from block for one source of truth 2025-02-12 19:09:21 +01:00
gingerBill 4c4b481ccc Merge pull request #4832 from bungoboingo/fix/sdl-window-bindings
Fix bindings for some window functions in SDL3
2025-02-12 08:53:06 +00:00
shan 9bf0b386ab Fix bindings for some window functions in SDL3 2025-02-11 17:50:20 -08:00
gingerBill 584fdc0d4a Merge pull request #4827 from denovodavid/pr-d3d12-vtable-fixes
vendor:directx/d3d12: fix some vtables
2025-02-11 10:32:20 +00:00
denovodavid ca17a5eb70 d3d12: fix some vtables 2025-02-11 16:58:26 +11:00
gingerBill 4678186cd2 Merge pull request #4815 from NotKyon/master
Win32 API: Add common comctl32 definitions and surrounding support structures.
2025-02-10 08:57:44 +00:00
Jeroen van Rijn bc100c3158 Merge pull request #4820 from Lperlind/tlsf_fixup
Fix tlsf block adjustment
2025-02-10 03:12:20 +01:00
Lucas Perlind 88a5817134 Fix tlsf block adjustment 2025-02-10 13:01:16 +11:00
Jeroen van Rijn 40cf9a33e9 Merge pull request #4817 from bplu4t2f/master
Add more win32 STARTF_* constants
2025-02-09 15:26:07 +01:00
kjdslf a14a4d9de7 Add more win32 STARTF_* constants 2025-02-09 15:01:23 +01:00
NotKyon ba9e723643 Win32: Fix strict style conformance. 2025-02-09 04:02:00 -08:00
NotKyon 2b36849004 Win32: Fix cross-platform compilation. 2025-02-09 03:50:51 -08:00
NotKyon ba280c8993 Win32: Fix -vet errors. 2025-02-09 03:36:37 -08:00
NotKyon a6188eda60 Add common Windows control messages, constants, structures, macros, and support. 2025-02-09 03:11:13 -08:00
Jeroen van Rijn 963663b8e1 Merge pull request #4814 from haesbaert/dns-cleanup
Cleanup allocated dns runtime data
2025-02-09 02:12:02 +01:00
Jeroen van Rijn fdc011555f Merge pull request #4813 from haesbaert/dns-fixes
Fix some compression bugs in dns.
2025-02-09 02:11:47 +01:00
Christiano Haesbaert cd53949c92 Cleanup allocated dns runtime data
While harmless, the runtime should clean up non-user allocated data.
On the same veign of: https://github.com/odin-lang/Odin/pull/4680

I'm kinda new to Odin and wrote netcat, in order to get a clean valgrind run,
one has to manually destroy dns_configuration:
https://github.com/haesbaert/learn-odin/blob/main/netcat/netcat.odin#L168-L169

While here unexport the destroy procedure and make destruction idempotent.
2025-02-09 00:26:25 +01:00
Christiano Haesbaert 605527f9db Fix some compression bugs in dns.
- A compression pointer is when the two higher bits are set, the code was
   considering only 0xC0 as a pointer, where in reality anything from 0xC0-0xFF is
   a pointer, probably went unnoticed since you need big packets to have long pointers.
 - Make sure we can access the lower byte of the pointer by checking len, the
   code was careful to not access past the first byte, but ignored the second.
 - As per RFC9267 make sure a pointer only points backwards, this one is not so
   bad, as the code had a iteration_max that ended up guarding against infinite jumps.

Lightly tested, some eyes are welcome, but these are remote DOSable.
2025-02-09 00:00:11 +01:00
Jeroen van Rijn 0683a3d672 Merge pull request #4681 from haesbaert/sockaddr
Add net.dial_tcp_from_host{_or_endpoint} and unify them
2025-02-08 12:45:02 +01:00
gingerBill 4ea96bd1c9 Merge pull request #4779 from jkenda/master
encoding/json: marshal enumerated arrays to objects with key-value pairs
2025-02-08 08:01:36 +00:00
gingerBill a347af49ca Clean up styling 2025-02-08 08:01:07 +00:00
gingerBill 5320d66efd Merge pull request #4783 from Lperlind/windows_game_input
Add windows game input to vendor
2025-02-08 07:51:06 +00:00
gingerBill fbee045023 Merge pull request #4797 from laytan/improve-abs-of-float
improve abs() on floats for more correct and faster results
2025-02-08 07:49:22 +00:00
gingerBill cf326df54b Remove #by_ptr and replace with Maybe(^T) where necessary 2025-02-08 07:37:40 +00:00
gingerBill d3488c70e6 Merge pull request #4807 from Dudejoe870/sdl3-iostream-fix
Fix the function signatures for the write procedures in sdl3_iostream.odin
2025-02-08 07:21:38 +00:00
Dudejoe870 5dc24a9130 Fix the function signatures for sdl3_iostream 2025-02-07 21:07:40 -06:00
gingerBill a5411199c7 Fix #4804 2025-02-07 13:37:09 +00:00
gingerBill 6189413906 Merge pull request #4790 from odin-lang/bill/sdl3
`vendor:sdl3`
2025-02-07 09:17:20 +00:00
gingerBill cec84edcdd Create sdl3_system.odin 2025-02-07 08:57:21 +00:00
gingerBill 3bf475deaf Add sdl3_vulkan.odin 2025-02-07 08:37:33 +00:00
gingerBill d1f2820ff5 Update sdl3_main.odin 2025-02-07 08:26:21 +00:00
gingerBill 4c93446e38 Fix typo 2025-02-07 08:11:16 +00:00
gingerBill 20708c60a1 Add sdl3_main.odin 2025-02-07 08:10:51 +00:00
gingerBill 8203281145 Add sdl3_hints.odin 2025-02-07 08:03:00 +00:00
gingerBill 58c4f13c82 Merge branch 'master' into bill/sdl3 2025-02-07 07:53:47 +00:00
gingerBill 667ddc1907 Merge pull request #4786 from korvahkh/fix-variants2ptrs
Preserve `#no_nil` in `intrinsics.type_convert_variants_to_pointers`
2025-02-07 07:30:14 +00:00
gingerBill 4e300b3fc8 Merge pull request #4796 from laytan/obfuscate-more
-obfuscate-source-code-locations on bounds checks and type assertions
2025-02-07 07:30:00 +00:00
gingerBill a9cd70a913 Merge pull request #4800 from laytan/make-use-separate-modules-corrected-linkage-hidden
make corrected linkage with -use-separate-modules apply hidden visibility
2025-02-07 07:28:18 +00:00
Lucas Perlind 932fcaee6b remove GAMEINPUT prefix 2025-02-07 09:49:04 +11:00
Laytan Laats 5defddffd0 reorganize tests and handle endian 2025-02-06 21:44:34 +01:00
Laytan Laats 9241d7c698 add tests for abs() on floats 2025-02-06 21:20:15 +01:00
Laytan Laats de83ad2a25 apply abs fix to constant system too 2025-02-06 21:19:54 +01:00
Laytan Laats 1053ec3051 make corrected linkage with -use-separate-modules apply hidden visibility
Fixes #4798

The DLL was using the type info of the host/exe, causing crashes.
This PR tries fixing by applying hidden visibility to these corrected
symbols which makes sure that the DLL can't see the type table of the host/exe.
2025-02-06 20:45:58 +01:00
Laytan Laats 80d09774b4 fix not using RTLD_LOCAL on darwin 2025-02-06 19:15:12 +01:00
Lucas Perlind cb10a060f1 Trailing commas 2025-02-06 15:03:56 +11:00
Lucas Perlind 24496c4046 Add game input to examples import 2025-02-06 14:57:47 +11:00
Lucas Perlind d1d0f0e9b7 Update 4 review 2025-02-06 14:56:37 +11:00
Laytan Laats b1068c7f2e improve abs() on floats for more correct and faster results 2025-02-05 21:17:48 +01:00
Laytan Laats b86d2c30b6 fix odin report macos version reporting unknown when release isn't a 3 point 2025-02-05 20:16:24 +01:00
Laytan Laats b77430bea8 -obfuscate-source-code-locations on bounds checks and type assertions 2025-02-05 19:42:20 +01:00
gingerBill 919e9a82e7 Merge pull request #4774 from Goldenlion5648/typo-correction-in-rand
fix typo in float32_range doc string
2025-02-05 11:59:59 +00:00
gingerBill 861a99cdc5 Merge pull request #4791 from roccoblues/ds/io-docs
`core:io` small documentation fixes
2025-02-05 11:59:17 +00:00
gingerBill 4667a19e77 Update to SDL 3.2.2 2025-02-05 11:07:08 +00:00
gingerBill 0ca614361a Update and add gamecontrollerdb.txt 2025-02-05 10:49:25 +00:00
gingerBill bce43aa7dc Make parameter Maybe(^T) 2025-02-05 10:49:14 +00:00
gingerBill 898bea8a97 Split-up require_results foreign blocks 2025-02-05 10:41:45 +00:00
gingerBill 61558ca163 Merge pull request #4789 from jfcode4/master
[core/strings] Fix _split_iterator when separator is empty
2025-02-05 10:34:49 +00:00
gingerBill 83542a3f04 Add struct field tag fmt formatting 2025-02-05 10:30:14 +00:00
gingerBill 802895aa43 Remove random extra newline 2025-02-05 10:27:41 +00:00
gingerBill f80bea5b11 Remove transmute suggestion with -vet-cast when transmuting native <-> endian-specific types 2025-02-05 10:27:17 +00:00
gingerBill ab469e657d Remove debug code 2025-02-05 10:20:18 +00:00
Dennis Schön fbf536f465 core:io small documentation fixes 2025-02-04 21:27:44 +01:00
gingerBill e967f4596f Update vendor/sdl3/sdl3_cpuinfo.odin
Co-authored-by: Laytan <laytanlaats@hotmail.com>
2025-02-04 19:58:39 +00:00
Jacob Friedman 385f5f5014 Small optimization 2025-02-04 19:51:48 +01:00
gingerBill f7028aa46c Fix typo 2025-02-04 17:33:30 +00:00
gingerBill 7380f31e05 Add vendor:sdl3 to ci.yml 2025-02-04 17:13:15 +00:00
gingerBill fbac23a631 Change foreign import for sdl3 2025-02-04 17:08:39 +00:00
gingerBill 06902818bf Add gl_set_proc_address 2025-02-04 17:06:05 +00:00
gingerBill 0376061a79 Add SDL3 to examples/all/all_vendor.odin 2025-02-04 17:01:15 +00:00
gingerBill d4b1ff31ae Revert build.bat 2025-02-04 17:00:01 +00:00
gingerBill a62ce5cc66 Add sdl3_tray.odin and sdl3_version.odin 2025-02-04 16:59:38 +00:00
gingerBill 98271f0073 Add sdl3 time/timer 2025-02-04 15:50:57 +00:00
gingerBill 84cb2440b2 Add sdl3_filesystem.odin and sdl3_storage.odin 2025-02-04 15:43:58 +00:00
gingerBill 16dce5b85d Add more sdl3 files 2025-02-04 15:34:52 +00:00
gingerBill 72f69d1bac Add sdl3_log.odin 2025-02-04 14:49:55 +00:00
Jacob Friedman 4c0b145bad Fix unicode handling 2025-02-04 15:49:23 +01:00
gingerBill 14ea47c420 Add sdl3_locale.odin 2025-02-04 14:41:54 +00:00
gingerBill a7d57e69ec Add sdl3_loadso.odin 2025-02-04 14:35:06 +00:00
gingerBill 77ba5faf09 Add sdl3_init.odin 2025-02-04 14:31:53 +00:00
gingerBill 2b4fbf695c Add sdl3_events.odin 2025-02-04 14:31:36 +00:00
Jacob Friedman 239c511ce9 Fix strings.split_iterator when separator is empty 2025-02-04 15:09:12 +01:00
gingerBill f1ab08a069 Add sdl3_hidapi.odin 2025-02-04 12:54:23 +00:00
gingerBill 44d31cb4a3 Add sdl3/sdl3_haptic.odin 2025-02-04 12:48:40 +00:00
gingerBill ce69161ffb Add sdl3_gpu.odin 2025-02-04 12:23:25 +00:00
gingerBill 02fcac195b Add sdl3_gamepad.odin 2025-02-04 10:31:56 +00:00
gingerBill 086d7956b1 Merge branch 'master' into bill/sdl3 2025-02-04 10:31:12 +00:00
korvahkh 1281303ff7 Preserve #no_nil in intrinsics.type_convert_variants_to_pointers
Previously the newly returned type would not be marked as `#no_nil`.
This caused `reflect.get_union_as_ptr_variants`
to break on `#no_nil` unions.
2025-02-03 16:08:19 -06:00
gingerBill 0e1c89e99b Merge pull request #4781 from NotKyon/master
Add miscellaneous missing WinAPI functions, constants, and structures (comctl32, user32, uxtheme)
2025-02-03 08:15:34 +00:00
Lucas Perlind 9cbbe72f6f Add windows game input to vendor 2025-02-03 10:33:32 +11:00
gingerBill dc7cd21986 Merge pull request #4782 from Daxode/nsstring-appendingstring
Add stringByAppendingString to NSString
2025-02-02 07:01:16 +00:00
daniel.andersen c8a537aad9 Add stringByAppendingString to NSString 2025-02-02 03:26:07 +01:00
NotKyon bdf2a587c3 Add miscellaneous missing WinAPI functions, constants, and structures for comctl32, user32, and ux_theme. 2025-02-01 16:17:28 -08:00
jkenda 51b80c5a20 encoding/json: marshal enumerated arrays to objects with key-value pairs 2025-02-01 10:32:07 +01:00
gingerBill a219da14ce Fix gb.h's gb_fprintf_va to allocate if the string is larger than the default buffer 2025-01-31 09:43:30 +00:00
gingerBill 05a2d1bfbf Fix #4750 2025-01-31 09:34:38 +00:00
gingerBill 2af60b8767 Fix #4763 2025-01-31 09:30:15 +00:00
gingerBill a94ffefba3 Add OpenEXRCore-3_3.lib 2025-01-31 09:06:31 +00:00
gingerBill 61cd0f4de9 Update OpenEXRCore to 3.3 2025-01-31 09:04:26 +00:00
gingerBill 539a74c2a9 Fix bindings for sys/linux and posix/unistd.odin 2025-01-31 08:37:43 +00:00
gingerBill 5d758cd020 Merge branch 'master' of https://github.com/odin-lang/Odin 2025-01-31 08:34:21 +00:00
gingerBill 0cd20e61ab Add @(export) foreign import 2025-01-31 08:34:15 +00:00
gingerBill f6001e1b0c Merge pull request #4775 from duffn/duffn/nssavepanel-tabs
Fix tab indents in NSSavePanel
2025-01-31 07:31:52 +00:00
ed f0b81f6502 Merge remote-tracking branch 'offical/master' 2025-01-30 14:36:46 -05:00
gingerBill 90fd4ffbba Add sdl3_joystick.odin 2025-01-30 14:48:09 +00:00
gingerBill 54caf5f576 Add sdl3_sensor.odin 2025-01-30 14:36:50 +00:00
gingerBill 83c5c08010 Add sdl3_power.odin 2025-01-30 14:33:20 +00:00
gingerBill 01365fa6b8 Add sdl3_mutex.odin 2025-01-30 14:32:06 +00:00
gingerBill 76b697edde Add sdl3_thread.odin 2025-01-30 14:31:54 +00:00
gingerBill 66ae71f619 Add sdl3_guid.odin 2025-01-30 14:17:08 +00:00
gingerBill a194e05bac Add sdl3_dialog.odin 2025-01-30 14:14:29 +00:00
gingerBill a3f50024c0 Add sdl3_video.odin 2025-01-30 14:11:02 +00:00
gingerBill e14fee9bb4 Add sdl3_cpuinfo.odin 2025-01-30 13:34:22 +00:00
gingerBill a31eb5b666 Add sdl3_clipboard.odin 2025-01-30 13:32:49 +00:00
gingerBill 2c908aa160 Add sdl3_camera.odin 2025-01-30 13:32:38 +00:00
gingerBill 6c80fb3de5 Add sdl3_surface.odin 2025-01-30 13:29:44 +00:00
gingerBill c0d9d1070f Add sdl3_rect.odin 2025-01-30 13:29:25 +00:00
gingerBill 36b27c081d Add sdl3_pixels.odin 2025-01-30 13:11:05 +00:00
gingerBill bf7c192ce9 Keep -vet and -strict-style happy 2025-01-30 12:22:22 +00:00
gingerBill 376f6a6b77 Add sdl3_blendmode.odin 2025-01-30 12:20:35 +00:00
gingerBill 22a08bb8de Add sdl3_bits.odin 2025-01-30 12:14:40 +00:00
gingerBill 1e699c08b9 Add sdl3_audio.odin 2025-01-30 12:11:42 +00:00
gingerBill 8c453ecc22 Add sdl3_iostream.odin 2025-01-30 11:58:28 +00:00
Jeroen van Rijn 77c91c82ff Merge pull request #4776 from candtechsoftware/master
Added IP_ADD_MEMBERSHIP to  Socket_Option on Linux
2025-01-30 12:56:07 +01:00
gingerBill 36d7f90ede Add sdl3_properties.odin 2025-01-30 11:48:14 +00:00
gingerBill b7740861c4 Add sdl3_error.odin 2025-01-30 11:43:33 +00:00
gingerBill 14c07ff011 Add sdl3_endian.odin 2025-01-30 11:39:55 +00:00
gingerBill 4093026a9a Clean up @(export) foreign import code 2025-01-30 11:36:12 +00:00
gingerBill 6d596adcdc Add sdl3_atomic.odin 2025-01-30 11:30:49 +00:00
gingerBill b48f14ba82 @(export) foreign import to be package scope level 2025-01-30 11:30:38 +00:00
gingerBill 22d6cabcdc Add sdl3_asyncio.odin 2025-01-30 11:16:39 +00:00
gingerBill 6a58d76c8a Add sdl3_assert.odin 2025-01-30 11:11:09 +00:00
gingerBill 4bef810b20 Fix sdl3/sdl3_stdinc.odin 2025-01-30 10:40:13 +00:00
gingerBill 5efa3510cf Merge branch 'master' into bill/sdl3 2025-01-30 10:37:21 +00:00
candtechsoftware 97db18c09a Added IP_ADD_MEMBERSHIP Socket Option on Linux 2025-01-29 23:12:32 -05:00
duffn af63db5075 Fix tab indents in NSSavePanel 2025-01-29 16:06:19 -07:00
Colter d5d900e292 fix typo in float32_range doc string 2025-01-29 12:20:07 -05:00
gingerBill 2656ecd4e1 Fix #4773 - Change order of evaluation for slicing indices 2025-01-29 15:53:34 +00:00
Laytan 5ebc31edcb Merge pull request #4580 from tf2spi/4485-fix-exact-value-float
Fix parsing of integer w/ 'e' notation
2025-01-29 07:28:40 +01:00
gingerBill 0e27acd755 Update NSSavelPanel 2025-01-28 11:38:06 +00:00
gingerBill 15ece42e74 Print frameworks first on Darwin targets 2025-01-28 10:34:41 +00:00
gingerBill 868ab27720 Add @(ignore_duplicates) for foreign import declarations 2025-01-28 10:31:46 +00:00
Jeroen van Rijn e7cf6c3275 Merge pull request #4769 from Kelimion/mdns
Add tentative mDNS/Bonjour/Avahi query support to `net.resolve`
2025-01-27 23:11:53 +01:00
Jeroen van Rijn cc29bdaefc Simplify *nix mDNS 2025-01-27 23:04:15 +01:00
Jeroen van Rijn 8998d74a92 Add mDNS for *nix. 2025-01-27 22:55:48 +01:00
Jeroen van Rijn d85c2c1ca7 Add mDNS/Bonjour/Avahi (.local) support for Windows 2025-01-27 22:16:24 +01:00
Laytan Laats 34aa326d99 put FILE in core:c and use that in bindings to fix wasm 2025-01-27 19:00:04 +01:00
gingerBill f918bc9f50 Merge pull request #4748 from nadako/fix-raylib-CameraMoveRight-signature
fix raylib.CameraMoveRight signature
2025-01-27 10:00:09 +00:00
gingerBill 00dfb1d125 Merge pull request #4765 from p1xelHer0/master
Vendor - miniaudio - engine: fix sound_config_init2
2025-01-27 09:59:49 +00:00
gingerBill 945f9acedd Merge pull request #4764 from samuelgozi/fix-send-missing-flags
Pass flags down from `os.send` in darwin and linux
2025-01-27 09:59:30 +00:00
gingerBill 2e64cf7ef5 Merge pull request #4751 from Barinzaya/arena-grow-in-place
Grow-in-place for some arenas
2025-01-27 09:59:09 +00:00
p1xelHer0 72bbbc94a9 Vendor - miniaudio - engine: fix sound_config_init2
The new way to init `sound_group` and `sound_group_config` is currently
using a binding that doesn't match the miniaudio API.
The functions in miniaudio have an underscore between the `init` and `2`.
This fixes this.
2025-01-26 23:36:35 +01:00
Samuel Elgozi 61f02d9f49 pass flags down from os.send in darwin and linux 2025-01-26 14:03:45 +02:00
gingerBill 6572a52a84 Merge pull request #4743 from starlitcanopy/fix-matrix-mul
Fix 2x2 matrix inverses in specific.odin
2025-01-25 08:35:46 +00:00
Laytan 17f017ed87 Merge pull request #4758 from laytan/fix-duplicate-linker-warning
fix duplicate linker warning on macos
2025-01-25 01:04:54 +01:00
Laytan Laats f957542cd3 fix duplicate linker warning on macos
Fixes #4747
2025-01-25 00:50:57 +01:00
Laytan 4d3fe34c88 Merge pull request #4754 from laytan/fix-separate-modules-objc
Fix separate modules objc
2025-01-24 20:25:54 +01:00
Laytan Laats 9dc17f4c47 optimize fix 2025-01-24 19:33:57 +01:00
Laytan Laats b2aaf90f88 fix separate modules with objc code 2025-01-24 19:23:49 +01:00
Barinzaya 98b3a9eacd Added support for growing in place to some arenas.
This affects `runtime.Arena` and `virtual.Arena`, but not currently
`mem.Arena`. These changes allow the last allocation that has been
made to be resized to a larger size by just extending their
allocation in-place, when there's sufficient room in the memory block to
do so.

Shrinking in place and re-using the rest of the allocation can be
supported using almost the same logic, but would require the memory to
be zeroed. Since this would add a additional cost that isn't currently
present, shrinking has not been changed.
2025-01-24 10:13:46 -05:00
gingerBill 3a13c598e2 Merge pull request #4733 from laytan/get-executable-path
os/os2: add get_executable_path and get_executable_directory
2025-01-24 13:09:10 +00:00
gingerBill 13a2a29b90 Merge pull request #4730 from laytan/os2-linux-loop-writes-and-cap-rw
os/os2: bring Linux to other impls standards by looping writes and maxing one shot RW sizes
2025-01-24 13:03:29 +00:00
gingerBill 1a7d2ca2e1 Merge pull request #4745 from flysand7/fmt-sign-pad
Fix the '+' sign placement in the presence of '0'-padding
2025-01-24 13:01:43 +00:00
Dan Korostelev f57048f862 fix raylib.CameraMoveRight signature 2025-01-24 01:13:53 +01:00
flysand7 7127992625 Fix the '+' sign placement in the presence of '0'-padding 2025-01-24 08:36:01 +11:00
gingerBill 998d6525b7 stdinc 2025-01-23 14:13:15 +00:00
prescientmoon 5a29e80bc3 Fix 2x2 matrix inverses in specific.odin 2025-01-23 05:56:27 +01:00
Laytan Laats d54de6704a os/os2: use proc_pidpath for executable path on darwin 2025-01-22 18:40:06 +01:00
gingerBill 9e9f9d34f5 Add SDL3 headers and Windows dll/lib 2025-01-22 17:20:51 +00:00
gingerBill 867af80bff Add -use-single-module 2025-01-22 13:26:35 +00:00
gingerBill d4e15074ea Enable -use-separate-modules as default for all platforms 2025-01-22 13:13:00 +00:00
gingerBill dde3a03022 Add priority_index to Foundation.framework import in base:runtime 2025-01-22 13:03:51 +00:00
gingerBill d6633639dc Remove duplicates of .framework/.dynlib/.so in linker 2025-01-22 13:01:06 +00:00
gingerBill 36e86ba552 Merge pull request #4739 from jasonKercher/fix-4738
fix compiler crash on assigning a variable to an unresolved bit_set
2025-01-22 10:38:23 +00:00
gingerBill 2619167fd0 Merge pull request #4741 from wrathdoesthat/master
Add GetTempFileNameW
2025-01-22 10:37:23 +00:00
wrathdoesthat 57b8da79f4 Add GetTempFileNameW 2025-01-22 04:33:33 -05:00
jason e85667c95c fix grammar in error message 2025-01-21 20:48:11 -05:00
jason b25ca0bb11 fixes compiler crash on syntax error (issue 4738) 2025-01-21 20:37:17 -05:00
Laytan Laats f1b0b19710 os/os2: get_executable_path and working directory on wasi 2025-01-21 19:14:15 +01:00
Laytan Laats b673642412 os/os2: add get_executable_path and get_executable_directory 2025-01-21 18:54:45 +01:00
gingerBill 223970671f Merge pull request #4716 from laytan/os2-wasi
os/os2: wasi target support
2025-01-21 13:08:04 +00:00
gingerBill 1cfbef3172 Merge pull request #4735 from NicknEma/activation-context-windows
Add ACTCTX definition and procs
2025-01-21 13:06:55 +00:00
NicknEma 55abf61836 Add ACTCTX definition and procs 2025-01-21 10:55:39 +01:00
flysand7 5d290dce06 Merge branch 'simd-docs' into docs-simd 2025-01-21 11:45:51 +11:00
flysand7 b7afbd6d57 Suggestion fixes 2025-01-21 11:15:00 +11:00
Laytan 68653081be Merge pull request #4732 from zen3ger/os2-process-incorrect-working-dir
os/os2: Properly update CWD on Linux when using _process_start()
2025-01-21 00:07:32 +01:00
Roland Kovacs f6ead2e777 os/os2: Linux _process_start() write back error on fchdir failure 2025-01-20 23:31:13 +01:00
Roland Kovacs ac30d36206 os/os2: Properly update CWD on Linux when using _process_start()
The `dir_fd` argument to `execveat()` is not for setting the current working
directory. It is used to resolve relative executable paths, hence explicit
`chdir/fchdir` call is required to set CWD.
2025-01-20 22:34:49 +01:00
Laytan Laats bf58107402 os/os2: bring Linux to other impls standards by looping writes and maxing one shot RW sizes 2025-01-20 20:15:03 +01:00
Laytan Laats a5f3c1b849 container/queue: fix init_with_contents
Fixes #4729
2025-01-20 19:51:46 +01:00
gingerBill 70257c846e Merge pull request #4707 from samuelgozi/add-Foundation-bindings
Added Foundation bindings
2025-01-20 14:42:27 +00:00
gingerBill 5644f3c3d9 Merge pull request #4725 from dozn/fix-dst-timezones
Fix Times Which Support DST on Windows
2025-01-20 14:24:48 +00:00
gingerBill b36b7c1f15 Merge pull request #4727 from karl-zylinski/examples-link-in-readme
Add examples link to README
2025-01-20 14:23:14 +00:00
Karl Zylinski 4950a65b09 Add examples link to README 2025-01-20 14:46:27 +01:00
dozn dfd826ed86 Fix Times Which Support DST on Windows 2025-01-20 03:57:36 -08:00
gingerBill 00a3a8dc81 Merge pull request #4714 from laytan/fix-map-entry-wrong-key-ptr
fix map_entry sometimes giving wrong key pointer
2025-01-20 07:41:47 +00:00
Laytan bca016ae94 Merge pull request #4720 from jasonKercher/remove-custom-heap-allocator
os2/heap_linux point to runtime._heap_allocator_proc
2025-01-19 13:34:11 +01:00
jason 27998e0d21 os2/heap_linux point to runtime._heap_allocator_proc 2025-01-19 06:05:55 -05:00
Laytan 20fa9fbd61 Merge pull request #4717 from LineuVale/fixDrawRectangleRoundedLines
Fix raylib DrawRectangleRoundedLines
2025-01-18 22:55:51 +01:00
Laytan Laats 5622fb583c math/rand: add @(require_results) to create 2025-01-18 22:52:13 +01:00
Laytan f8c2aa9316 Merge pull request #4713 from Rexicon226/matrix-errors
fix inverted error messages
2025-01-18 22:46:41 +01:00
Laytan 6f24eb87c0 Merge pull request #4697 from JamesDSource/master
Allow captures in gfind and gmatch to be used in-loop
2025-01-18 22:36:19 +01:00
Laytan Laats e4892f1bb2 os/os2: wasi target support 2025-01-18 22:23:44 +01:00
LineuVale 21e4888934 Fix raylib DrawRectangleRoundedLines 2025-01-18 18:22:16 -03:00
Samuel Elgozi 0f12618642 fix incorrect use of Bool 2025-01-18 21:08:54 +02:00
Laytan Laats 4de5911a15 fix map_entry sometimes giving wrong key pointer
`map_desired_position` does not return the actual position, probing must
be done afterwards to figure out the real position. `map_entry` did not
do this for the returned key pointer so it could point to the wrong key
if probing was done.
2025-01-18 14:02:27 +01:00
David Rubin 5951c25f71 fix inverted error messages 2025-01-18 02:04:35 -08:00
Laytan 47030501ab Merge pull request #4585 from wrapperup/miniaudio-bitsets
`vendor:miniaudio`: Use bit sets for flags
2025-01-17 18:42:46 +01:00
Laytan 8e9726866a remove other redundant constant 2025-01-17 18:31:39 +01:00
gingerBill 328d70e244 Merge pull request #4696 from alektron/ArenaBug
Non-zeroed memory after Arena free
2025-01-17 14:20:28 +00:00
gingerBill ed18f539c7 Merge pull request #4698 from 4teapo/mem-additions
Add SoA make/delete to core:mem
2025-01-17 14:20:02 +00:00
gingerBill b9bf5b1496 Merge pull request #4703 from flysand7/4685-range-stack-overflow
Do not warn about stack overflow in range loops 'by reference'
2025-01-17 13:23:15 +00:00
gingerBill fcd3cf7fa8 Merge pull request #4704 from flysand7/4614-thread-locals
Error if `-no-crt` is used without `-no-thread-locals`
2025-01-17 13:22:47 +00:00
Samuel Elgozi 3fb766f98d updated to meet formatting style 2025-01-17 13:43:34 +02:00
Samuel Elgozi 19d6c01f0f Added Foundation bindings 2025-01-17 10:42:32 +02:00
flysand7 3f20b63243 Error if -no-thread-local is used in presence of -no-crt on Unix 2025-01-17 02:51:22 +03:00
flysand7 4f0206ce08 Added compile-time checks for thread locals with -no-crt
Now using any thread-local variables with -no-crt enabled
will cause a compiler error, unless -no-thread-local is
given.

Also fixed a minor typo in a comment.
2025-01-17 01:12:23 +03:00
flysand7 87b590c99b Do not warn about stack overflow in range loops 'by reference' 2025-01-16 22:11:30 +03:00
Laytan 16eca1ded1 Merge pull request #4702 from flysand7/4632-futex-windows
[sync]: Fix typos in comments and remove my note.
2025-01-16 18:05:51 +01:00
flysand7 9da144157e [sync]: Fix typos in comments and remove my note. 2025-01-16 19:33:09 +03:00
James Duran 13640620ce Fix captures not begin zeroed when haystack length is 0 2025-01-15 15:56:40 -08:00
Laytan Laats aa3f0b86c1 compiler: fix align error check 2025-01-15 20:18:50 +01:00
teapo 4895065afb Add SoA make/delete to core:mem 2025-01-15 20:16:57 +01:00
James Duran a7971f9f6f Allow captures in gfind and gmatch to be used in-loop 2025-01-15 11:02:46 -08:00
alektron 32d747cf8b Merge branch 'master' into ArenaBug 2025-01-15 18:00:29 +01:00
alektron a0c20023fc Fix: Issue with non-zeroed memory after arena_temp_and;
Fix: total_used field of growing Arena was not decremented correctly in arena_temp_end;
2025-01-15 17:59:30 +01:00
Laytan e55b652916 Merge pull request #4678 from clindholm/glfw_get_monitor_workarea
vendor/glfw: add GetMonitorWorkarea binding
2025-01-15 10:37:42 +01:00
Laytan 0cb04f5153 Merge pull request #4691 from harold-b/fix-unused-define-crash-when-ignore-warnins
Fixes crash when unused defines are used in conjunction with `-ignore-warnings`
2025-01-15 10:37:15 +01:00
Harold Brenes 794e812932 Fixes crash when unused defines are used in conjunction with -ignore-warnings. 2025-01-15 02:04:49 -05:00
Laytan 432c49e214 Merge pull request #4689 from karl-zylinski/d3d12-tabs-fix
d3d12 bindings -vet-tabs fix
2025-01-14 06:11:57 +01:00
ed a761893d79 Built stb linux archives 2025-01-13 20:23:35 -05:00
Karl Zylinski 1613728a64 d3d12 bindings -vet-tabs fix 2025-01-13 23:37:36 +01:00
gingerBill 440acc42a9 Merge pull request #4686 from laytan/ensuref-and-other-fixes
add ensure and ensuref to fmt and log, fix some inconsistencies
2025-01-13 20:38:36 +00:00
Laytan Laats 9d4fa39daa add ensure and ensuref to fmt and log, fix some inconsistencies 2025-01-13 20:33:49 +01:00
gingerBill 48a7ed01f8 Merge pull request #4675 from jasonKercher/os2-dir-linux
Implement os2 dir linux
2025-01-13 11:04:55 +00:00
ed 7e6dde26ad Move setting arena backing ot default temp allocator, forgot assert for arena_alloc in default_temp_allocator_arena 2025-01-13 01:33:59 -05:00
ed 106bd8ab80 Update readme with latest list 2025-01-12 22:08:10 -05:00
ed ca2d0f81f0 Set allocator in base:runtime/core_builtin: make_map_cap & base:runtime/core_builtin_soa: make_soa_dynamic_array_len 2025-01-12 21:58:57 -05:00
ed 5a7b8b463b Removed implicit assignments for container allocators in the Base and Core packages 2025-01-12 21:41:15 -05:00
Jeroen van Rijn 600e0ebed0 Fix stray space vs. tab 2025-01-12 12:13:29 +01:00
ed 37ec315a91 odin/codegen: add args slice to UnrollRangeStmt 2025-01-11 22:09:40 -05:00
ed cb1ffad6f4 Merge remote-tracking branch 'offical/master' 2025-01-11 22:06:08 -05:00
Christiano Haesbaert 5699c533c6 Add net.dial_tcp_from_host{_or_endpoint} and unify them
The main motivation for this is to have sinergy with flags parsing, currently
flags for a sockaddr returns a net.Host_Or_Endpoint, but we can't just dial
from it since there isn't a variant.

Consider the following:

```
Options :: struct {
	target: net.Host_Or_Endpoint `args:"pos=0,required" usage:"host:port"`,
}

before :: proc() -> (sock: net.TCP_Socket, err: net.Network_Error) {
	opt: Options

	flags.parse_or_exit(&opt, os.args)
	switch t in opt.target {
	case net.Host:
		sock, err = net.dial_tcp(t.hostname, t.port)
	case net.Endpoint:
		sock, err = net.dial_tcp(t)
	}
	return
}

after :: proc() -> (sock: net.TCP_Socket, err: net.Network_Error) {
	opt: Options

	flags.parse_or_exit(&opt, os.args)
	sock, err = net.dial_tcp(opt.target)
	return
}

```

For completion, add dial_tcp_from_host() and define the upper functions in terms
of the newly added ones, cuts one repeated block, now:

from_hostname_and_port_string is parse + from_host_or_endpoint
from_hostname_with_port_override is parse + override + from_host_or_endpoint
from_host is to_endpoint + from_endpoint
from_host_or_endpoint is from_endpoint or from_host
2025-01-12 02:41:35 +01:00
Christiano Haesbaert c51df72f1a Make sure we don't leak os.args. Fixes #1633.
os.args is never freed, while this is an insignificant leak, it is a bit
annoying as it makes valgrind complain:

==234270== Memcheck, a memory error detector
==234270== Copyright (C) 2002-2024, and GNU GPL'd, by Julian Seward et al.
==234270== Using Valgrind-3.24.0 and LibVEX; rerun with -h for copyright info
==234270== Command: ./wc /tmp/mulumulu
==234270==
       1       8      58 /tmp/mulumulu
==234270==
==234270== HEAP SUMMARY:
==234270==     in use at exit: 47 bytes in 1 blocks
==234270==   total heap usage: 5 allocs, 4 frees, 4,195,875 bytes allocated
==234270==
==234270== 47 bytes in 1 blocks are possibly lost in loss record 1 of 1
==234270==    at 0x484BC13: calloc (vg_replace_malloc.c:1675)
==234270==    by 0x402E49: runtime._heap_alloc-769 (in /d/learn-odin/wc/wc)
==234270==    by 0x40A8D7: runtime.heap_alloc (in /d/learn-odin/wc/wc)
==234270==    by 0x436E9D: runtime.heap_allocator_proc.aligned_alloc-0 (in /d/learn-odin/wc/wc)
==234270==    by 0x4022DC: runtime.heap_allocator_proc (in /d/learn-odin/wc/wc)
==234270==    by 0x4165E0: runtime.make_aligned-22560 (in /d/learn-odin/wc/wc)
==234270==    by 0x41F6D0: runtime.make_slice-22340 (in /d/learn-odin/wc/wc)
==234270==    by 0x40156B: os._alloc_command_line_arguments-4679 (in /d/learn-odin/wc/wc)
==234270==    by 0x4011AF: __$startup_runtime (in /d/learn-odin/wc/wc)
==234270==    by 0x406F17: main (in /d/learn-odin/wc/wc)
==234270==
==234270== LEAK SUMMARY:
==234270==    definitely lost: 0 bytes in 0 blocks
==234270==    indirectly lost: 0 bytes in 0 blocks
==234270==      possibly lost: 47 bytes in 1 blocks
==234270==    still reachable: 0 bytes in 0 blocks
==234270==         suppressed: 0 bytes in 0 blocks
==234270==
==234270== For lists of detected and suppressed errors, rerun with: -s
==234270== ERROR SUMMARY: 1 errors from 1 contexts (suppressed: 0 from 0)

With the fix the leak is gone, tested on linux only.

While here, also make _alloc_command_line_arguments() private.
2025-01-11 21:55:09 +01:00
clindholm 93e8f5024e vendor/glfw: add GetMonitorWorkarea binding 2025-01-11 15:03:12 +01:00
jason c11dccf210 make -vet happy 2025-01-10 20:59:48 -05:00
jason fa7ef28acf Implement _read_directory_iterator in os2.
Also, fix minor bug in linux.dirent_name.
2025-01-10 20:54:09 -05:00
Laytan cd93e2f6f8 Merge pull request #4672 from shizeeg/master
add os.exists() to FreeBSD
2025-01-11 01:03:36 +01:00
Laytan Laats 896319d0d5 ci: test issues on windows 2025-01-11 01:00:15 +01:00
Laytan Laats e3c0cc9dfc time: add haiku 2025-01-11 00:18:36 +01:00
Laytan e4ae832775 Merge pull request #4603 from avanspector/master
Haiku: fix build and add initial `core:sys/posix` support
2025-01-11 00:06:29 +01:00
avanspector cc50fab8e3 Merge branch 'odin-lang:master' into master 2025-01-10 22:47:44 +01:00
avanspector ab7b5a5445 Haiku: change uintptr to uint where appropriate 2025-01-10 15:14:03 +01:00
gingerBill 328d893cb5 #unroll(N) for 2025-01-10 12:22:18 +00:00
gingerBill 4a2b13f1c2 Fix foreign import names 2025-01-10 10:18:30 +00:00
gingerBill b377ac182c Keep -vet happy 2025-01-10 10:15:15 +00:00
gingerBill fd058dff46 Merge branch 'master' of https://github.com/odin-lang/Odin 2025-01-10 10:12:42 +00:00
gingerBill 3d4a20918f Simplify stb foreign imports 2025-01-10 10:12:36 +00:00
gingerBill 5a259ed0ee Merge pull request #4669 from denovodavid/pr-d3d12-shader-component-mapping
vendor:directx/d3d12: add shader component mapping constants and macro-procedures
2025-01-10 09:44:17 +00:00
avanspector c686728184 Update dir_unix.odin 2025-01-10 07:15:44 +01:00
avanspector 0a985f5d02 Haiku: small fixes across core 2025-01-10 07:07:40 +01:00
avanspector 9868c8292b Merge branch 'master' of https://github.com/avanspector/Odin 2025-01-10 06:42:42 +01:00
avanspector a704000c34 Haiku: add posix tests 2025-01-10 06:42:19 +01:00
avanspector 5d3a069e7a Haiku: more posix 2025-01-10 06:40:29 +01:00
avanspector a6dccf5e98 Haiku: fix futex bug 2025-01-10 06:28:57 +01:00
avanspector 1dc5753a0f Merge branch 'odin-lang:master' into master 2025-01-10 06:26:36 +01:00
sh!zeeg 509da8e632 add os.exists() to FreeBSD 2025-01-10 05:56:56 +03:00
Laytan Laats 1511162b0a webgpu: fix cstring as parameter not loading correctly 2025-01-09 17:29:31 +01:00
gingerBill cabc76d9cb Merge pull request #4667 from laytan/use-map-entry-in-strings-intern
strings: use map_entry in Intern datastructure
2025-01-09 16:06:01 +00:00
denovodavid c30cdaa7b0 add d3d12 shader component mapping constants and macro-procedures 2025-01-09 11:39:01 +11:00
Laytan Laats 16e3abfe82 strings: use map_entry 2025-01-08 22:20:43 +01:00
Laytan Laats 2620721128 '#no_nil' I am actually disappointed in myself 2025-01-08 21:45:59 +01:00
Laytan Laats b3c359557e #no_nil third time's the charm 2025-01-08 21:24:22 +01:00
Laytan Laats 7185a93a86 actually fix #no_nil debug info
Fixes #4664
2025-01-08 20:24:31 +01:00
Laytan Laats 2aae4cfd46 fix #no_nil in debug info
Fixes #4664
2025-01-08 18:47:32 +01:00
gingerBill 30bb2250c7 Merge pull request #4474 from tf2spi/4407-mdei-pack
Pack MDEI struct to fix issue #4407
2025-01-08 16:41:47 +00:00
gingerBill 2a29322c91 Merge pull request #4605 from karl-zylinski/tracking-allocator-bad-free-default-to-crash
Make tracking allocator default to crashing on a bad free instead of adding to bad_free_array
2025-01-08 16:24:20 +00:00
gingerBill bc2e57723b Merge pull request #4665 from GrumpyLion/add_some_missing_win_functions
Add SetWindowSubclass and RegisterHotKey functions
2025-01-08 16:23:40 +00:00
flysand7 dfe3073cef [simd] Fixes to inputs/result/example/output sections & grmamar fixes 2025-01-08 16:47:12 +03:00
Lion Schitik ab3e2340c2 review 2025-01-08 12:38:28 +01:00
Laytan b71c74a357 Merge pull request #4666 from DaveTheGameDev/sys_windows
Fix name of RI_MOUSE_LEFT_BUTTON_DOWN containing S at the end in (user32.odin)
2025-01-08 07:46:47 +01:00
david_cauchi 9a68eb401d Fix name of RI_MOUSE_LEFT_BUTTON_DOWN containing S at the end 2025-01-08 15:06:17 +11:00
Lion Schitik cdef798fbc Add SetWindowSubclass and RegisterHotKey functions 2025-01-08 01:47:36 +01:00
Laytan Laats b136aa26c8 sys/windows: fix xinput build tag 2025-01-06 21:14:37 +01:00
ed e181b58966 Fix +build warning issue 2025-01-06 11:07:49 -05:00
ed 62a37b016c Merge remote-tracking branch 'offical/master'
# Conflicts:
#	vendor/raylib/raygui.odin
#	vendor/raylib/raylib.odin
2025-01-06 10:51:25 -05:00
ed f079345b8a Changed fontinfo passing to be immutable with #by_ptr directive when the c header's proc is 'const stbtt_fontinfo* info' 2025-01-06 10:46:55 -05:00
gingerBill 37a608664b Merge pull request #3208 from lordhippo/add-xinput
Add xinput bindings to core:sys/windows
2025-01-06 13:44:45 +00:00
gingerBill 6e49bbb668 Merge branch 'master' into d3d11-annotations 2025-01-06 13:43:01 +00:00
avanspector be7799459b Merge branch 'odin-lang:master' into master 2025-01-06 16:42:29 +04:00
gingerBill 98efb03934 Merge pull request #4599 from Barinzaya/fix_dynamic_resize_zeroing_on_grow
Fix dynamic array not zeroing when growing
2025-01-06 12:37:05 +00:00
gingerBill a6f1046fc0 Merge pull request #4533 from laytan/map-entry
add `map_entry` procedure
2025-01-06 12:36:27 +00:00
gingerBill 3d8bde9549 Merge pull request #4601 from Barinzaya/simd_vector_broadcasting
Implicit broadcasting for SIMD arrays
2025-01-06 11:15:28 +00:00
gingerBill f160ba4fa6 Merge pull request #4623 from Yawning/feature/rt-assert-ensure
base/runtime: Add `ensure` and `ensure_contextless`
2025-01-06 09:37:57 +00:00
gingerBill a3b4280cf7 Merge pull request #4633 from spahnke/fix-matrix-adjugate
Fix matrix adjugate
2025-01-06 09:36:18 +00:00
gingerBill c7739de891 Merge pull request #4634 from dozn/patch-1
Use Struct Tags For Embedded (with `using`) Structs When Unmarshalling JSON
2025-01-06 09:33:42 +00:00
gingerBill 16acb342d1 Merge pull request #4617 from gorevojd/free_bootstrapped_arena_crash
Fixed crash in arena_free_all() for bootstrapped growing arenas.
2025-01-06 09:33:23 +00:00
ed 7382244afc update readme 2025-01-06 01:25:02 -05:00
ed 3b7833ba65 Minor cleanup and remove unused
Also relaxed unnecessary constraint on ast fields for the using dbg.
2025-01-06 01:10:37 -05:00
ed a8e7fb584b Update using statement debug with src var added to name as 'struct_name::field_name' 2025-01-06 00:40:50 -05:00
ed e4d753d365 Update comments, better using statement debug
Procedure 'using' statements now dump references to the struct fields onto the stack in debug builds.
2025-01-05 23:38:59 -05:00
Laytan Laats 0cc1dbb092 vendor/box2d: clarify wasm building 2025-01-05 19:35:37 +01:00
Laytan Laats bf0e6eaf60 vendor/raylib: fix SetVertexAttribute definition
Fixes #4596
2025-01-05 19:21:39 +01:00
Laytan f566c5ee83 Merge pull request #4639 from flga/vulkan_xlib_xcb
`vendor:vulkan` Add support for xlib and xcb
2025-01-05 19:03:57 +01:00
Laytan 3a2396033c Merge pull request #4648 from lzurbriggen/fix/get-comm-ports
move GetCommPorts, add missing comm functions, add communication events
2025-01-05 18:53:36 +01:00
Laytan 00afd53f46 Merge pull request #4654 from obiwan87/master
Minor adjustments in documentation-only files for better LSP support
2025-01-05 18:52:19 +01:00
fleandro 25cdc3736e vendor:x11/xlib add IS_SUPPORTED constant to match core:time and friends 2025-01-05 17:50:52 +00:00
Leo Zurbriggen 823740c7a4 formatting 2025-01-05 18:43:16 +01:00
Laytan b98833ce04 spacing 2025-01-05 18:42:48 +01:00
Laytan 96513c8d5d Merge pull request #4636 from 2nafish117/update-to-cgltf-1.14
update cgltf from 1.13 to 1.14
2025-01-05 18:41:29 +01:00
Leo Zurbriggen c604926595 add SetCommMask, GetCommMask, WaitCommEvent, GetCommPorts, communication event constants 2025-01-05 18:04:36 +01:00
laytan 834209194f rebuild windows lib 2025-01-05 17:35:40 +01:00
Laytan Laats 252b807714 update wasm blob 2025-01-05 18:22:38 +01:00
gingerBill 7da7d4e410 Allow #+ tags on single files 2025-01-05 15:41:51 +00:00
gingerBill 5df699abf2 Add #+feature dynamic-literals to test 2025-01-05 14:03:08 +00:00
gingerBill 3d984d75cc Add #+feature dynamic-literals to tests 2025-01-05 14:00:23 +00:00
gingerBill a300a860ec Add #+feature dynamic-literals to tests 2025-01-05 13:46:58 +00:00
gingerBill 52d3497eda Merge branch 'master' of https://github.com/odin-lang/Odin 2025-01-05 13:33:16 +00:00
gingerBill bca08d3b85 Make -no-dynamic-literals the default now 2025-01-05 13:33:06 +00:00
Laytan bf77036cb0 Merge pull request #4651 from flga/runtime_map_get
runtime: map_cell_index_static produced wrong results when the number of elements per cell was a power of 2
2025-01-05 14:27:44 +01:00
Laytan aa4bc10a84 Merge pull request #4649 from dspx-plcr/master
add default -I and -L paths for OpenBSD
2025-01-05 14:23:51 +01:00
Laytan 73d1427127 Merge pull request #4662 from IllusionMan1212/jpeg-detection
fix(core/image): off-by-one index when detecting certain JPEG images
2025-01-05 14:23:35 +01:00
gingerBill 2efe4c2d68 Add #+feature dynamic-literals 2025-01-05 13:19:10 +00:00
gingerBill acbb14d87e Fix typo 2025-01-05 13:10:29 +00:00
gingerBill d718db473c Use array with linear search rather than a hash map. 2025-01-05 13:08:01 +00:00
gingerBill 4d63ee0794 Remove unused import 2025-01-05 12:55:35 +00:00
gingerBill 998a3b01cc Merge branch 'master' of https://github.com/odin-lang/Odin 2025-01-05 12:53:27 +00:00
gingerBill 1bf33fe373 Use static global memory for std handles instead of allocating. 2025-01-05 12:53:20 +00:00
Laytan Laats 5957ff3699 vendor/raylib: fix Vector3Unproject wrong assignment
Fixes #4646
2025-01-05 13:45:01 +01:00
Hisham Aburaqibah 247384574a fix(core/image): off-by-one index when detecting certain JPEG images 2025-01-05 13:05:11 +02:00
Jeroen van Rijn 397e371232 Merge pull request #4641 from zolk3ri/fix/base32-error-handling
encoding/base32: Add RFC-compliant error handling and improve reliability
2025-01-04 20:27:16 +01:00
gingerBill f5e5c9767c Merge pull request #4650 from jasonKercher/arm32-update
Arm32 update for sys/linux
2025-01-04 10:44:44 +00:00
gingerBill 872e6d0189 Merge pull request #4652 from VladPavliuk/extend_win32_api_types
Extend win32 api types
2025-01-04 10:42:28 +00:00
Antonino Simone Di Stefano ec1fefb3f5 Import "base:runtime" to resolve reference to type info correctly 2025-01-03 22:47:18 +01:00
Antonino Simone Di Stefano 630b1c5cdf Remove typeid
seems to be a typo
2025-01-03 22:47:18 +01:00
Antonino Simone Di Stefano d9165727f5 Make expect parameter polymorphic 2025-01-03 22:47:18 +01:00
Antonino Simone Di Stefano 6edb061061 Import "base:runtime" to make type references valid 2025-01-03 22:47:18 +01:00
Zoltán Kéri a4a1562905 encoding/base32: Add @(rodata) attribute to default tables
Add `@(rodata)` attribute to `ENC_TABLE` and `DEC_TABLE` to mark
them as read-only data. This places these tables in the read-only
section of the executable, protecting them from modification
during program execution.
2025-01-03 19:16:56 +01:00
VladPavliuk 1733a50678 Refactor changes. 2025-01-03 18:58:08 +02:00
fleandro 1550eced04 also add a test for non power of 2 N for good measure 2025-01-03 16:58:03 +00:00
VladPavliuk 470c05a902 Merge branch 'master' into extend_win32_api_types 2025-01-03 18:53:48 +02:00
VladPavliuk 36b5ca9176 Extend win32 types 2025-01-03 18:52:39 +02:00
fleandro c93e096d8f fix N=1 and cleanup tests 2025-01-03 16:50:05 +00:00
fleandro 555bca2cb4 fix test leaks 2025-01-03 15:46:02 +00:00
fleandro e3de02eaa8 runtime: map_cell_index_static produced wrong results when the number of elements per cell was a power of 2 2025-01-03 15:33:34 +00:00
jason 1221e393f7 add 32 bit Sig_Info and remove ppoll_time64 call 2025-01-03 09:29:39 -05:00
Despereaux Polacre 0b0ae52be5 add default -I and -L paths for OpenBSD 2025-01-02 21:31:34 +01:00
jason 074bef7baf Fix sys/linux 64 bit arguments on 32 bit systems
Reverese return values of compat64_arg_pair
Add register alignment to specific arm32 system calls
2025-01-02 14:50:45 -05:00
Leo Zurbriggen 4815d95128 move GetCommPorts to correct foreign block 2025-01-02 18:08:06 +01:00
jason ce1f3b34c0 Minor fixes + cleanup in os2 and sys/linux
Add NOFOLLOW to os2.remove
Change Dev from int to u64 and make relavant casts
Fix compat64_arg_pair
2025-01-02 11:03:24 -05:00
gingerBill fdd3b46c10 Merge pull request #4647 from karl-zylinski/raylib-wasm
Make it easier to do Raylib WASM builds
2025-01-01 21:32:08 +00:00
Karl Zylinski dc1b75b6c3 Added WASM libs for raylib and raygui. Added them to the foreign import blocks, with optional ways to override them. These overrides can be used to use alterantive libs when using for example emscripten. 2025-01-01 22:26:11 +01:00
Laytan 71b0f7e698 Merge pull request #4644 from karl-zylinski/box2d-build-script-fix
Fix for casing error in box2d/wasm.Makefile
2025-01-01 21:26:28 +01:00
Laytan 8763b15c61 Merge pull request #4643 from karl-zylinski/fix-vendor-libc-sin-log-types
Fix for vendor:libc using wrong types for log and sin procs.
2025-01-01 21:18:47 +01:00
Karl Zylinski f80c33727c Fix for casing error in box2d/wasm.Makefile 2025-01-01 21:15:44 +01:00
Karl Zylinski 51e90e5e96 Fix for vendor:libc using wrong types for log and sin procs. 2025-01-01 21:07:44 +01:00
gingerBill a2a0a2c8d8 Merge pull request #4611 from tf2spi/4491-max-field-align-pack
Add packing + aligned access w/ field_align
2025-01-01 18:03:44 +00:00
gingerBill 4882eefaf8 Merge pull request #4616 from flga/master
make -export-dependencies emit valid json
2025-01-01 17:46:25 +00:00
gingerBill 8a5c1b109d Merge pull request #4613 from fnknda/fix-linux-bind
Fix calls to bind always returning EINVAL when using linux.Sock_Addr_In
2025-01-01 17:46:15 +00:00
gingerBill bfbcc02aff Merge pull request #4608 from zen3ger/assignment-of-non-specialized-parapoly
Fix crash on assignment of parapoly proc to variable
2025-01-01 17:40:40 +00:00
gingerBill 8d400f43fd Merge pull request #4607 from zen3ger/parapoly-proc-fixes
Fix crash when proc return type is undeclared parapoly variable
2025-01-01 17:40:04 +00:00
gingerBill 7248958fcd Merge pull request #4606 from chris-montero/fix_memory_leak_in_core_prof_spall_doc_example
fixed memory leak in core/prof/spall/doc.odin example code
2025-01-01 17:39:20 +00:00
gingerBill 7b334d2bd9 Add #branch_location 2025-01-01 17:26:15 +00:00
gingerBill 1cf7a56ba7 General clean up of code 2025-01-01 15:13:46 +00:00
gingerBill 6383fddb59 Disable the os-specific code in libc so that non-OS specific platforms still work with it 2025-01-01 15:13:36 +00:00
gingerBill 049359cae4 Clean up box2d foreign import 2025-01-01 15:13:07 +00:00
gingerBill c8ad2a4245 Support multiple paths for wasm in foreign import 2025-01-01 15:12:54 +00:00
Zoltán Kéri fe88c22b1f encoding/base32: Fix RFC 4648 references and add RFC reference URL
Fix incorrect RFC 4648 section references:
- Add RFC URL reference at package level
- Update Error enum documentation to reference correct sections:
  - Invalid_Character: Section 3.3 (non-alphabet characters)
  - Invalid_Length: Section 6 (base32 block size requirements)
  - Malformed_Input: Section 3.2 (padding)
- Fix test file section references to match correct sections

This ensures all RFC references are accurate and adds a link to the
source RFC for reference.
2024-12-31 23:47:33 +01:00
Zoltán Kéri d6f4412dc3 encoding/base32: Fix style issues for CI 2024-12-31 18:59:39 +01:00
fleandro 98967aad74 vendor:vulkan Use vendor:x11/xlib types when available 2024-12-31 02:44:42 +00:00
Laytan 7ffec820ac Merge pull request #4610 from blob1807/master
Fix io.write_escaped_rune not writing full value
2024-12-30 23:53:24 +01:00
Laytan c02710cce8 Merge pull request #4638 from DataResearch/master
Added proc to user32 Bindings
2024-12-30 23:53:04 +01:00
Laytan a73c7be8f7 Merge pull request #4600 from jasonKercher/arm64-linux-fixes
Get arm64 up to speed in os2 linux
2024-12-30 23:38:59 +01:00
CodingChris bddca04b25 added IsZoomed to user32 bindings in sys/windows 2024-12-30 23:20:08 +01:00
fleandro 0d0a202a78 vendor:vulkan Add support for xlib and xcb 2024-12-30 22:09:27 +00:00
Zoltán Kéri 3d25128520 encoding/base32: Convert files to UTF-8 with Unix line endings 2024-12-30 15:31:57 +01:00
Zoltán Kéri 5ce6990077 encoding/base32: Add proper cleanup for encoded strings in tests
Add defer delete for encoded strings across all test procedures to ensure
proper cleanup and prevent memory leaks. This completes the memory
management improvements started in 591dd876.
2024-12-30 15:26:42 +01:00
Zoltán Kéri 8292509769 encoding/base32: Add custom alphabet test case
Add test case to verify custom alphabet support. The test uses a
decimal-uppercase alphabet (0-9, A-V) to test both encoding and decoding
with custom tables, including validation. This ensures the encode and
decode functions work correctly with custom encoding tables and
validation functions as documented.
2024-12-30 15:18:38 +01:00
Zoltán Kéri 591dd8765a encoding/base32: Remove incorrect defer delete in encode()
Remove premature deallocation of the output buffer which was causing
use-after-free behavior. The returned string needs to take ownership
of this memory, but the defer delete was freeing it before the
string could be used. This fixes issues with encoding that were
introduced by overly aggressive memory cleanup in 93238db2.
2024-12-30 12:00:38 +01:00
Zoltán Kéri 0d4c0064d9 encoding/base32: Add encode->decode roundtrip test
Add test_base32_roundtrip() to verify the encode->decode roundtrip
preserves data integrity. This test helps ensure our base32 implementation
correctly handles the full encode->decode cycle without data loss or
corruption.
2024-12-30 03:03:50 +01:00
Zoltán Kéri c9c59edc64 encoding/base32: Move tests to base32_test.odin
Move existing test procedures to a dedicated test file for better
code organization and maintainability.
2024-12-29 23:35:01 +01:00
shashank 3e63f598a0 build cgltf lib 2024-12-29 20:07:36 +05:30
shashank 77511da195 update cgltf from 1.13 to 1.14 2024-12-29 19:58:55 +05:30
dozn 87c159c69f Remove unnecessary string() conversion. 2024-12-28 08:13:38 -08:00
dozn d22cb20d85 Use Struct Tags For Embedded (with using) Structs When Unmarshalling JSON
A fix for https://github.com/odin-lang/Odin/issues/4539
2024-12-28 07:48:09 -08:00
Sebastian Pahnke b21fc19233 Add regression tests for inverse_transpose 2024-12-28 10:29:44 +01:00
Sebastian Pahnke ec5ee19c01 Add regression tests for matrix inverse 2024-12-28 10:29:44 +01:00
Sebastian Pahnke 02a9d8560f Test symmetry 2024-12-28 10:29:44 +01:00
Sebastian Pahnke f23e226854 Rename adjugate to cofactor to keep existing usages for inverse and determinant correct and add new adjugate procedures 2024-12-28 10:29:43 +01:00
Sebastian Pahnke 0d955e55db Add tests for determinants because their calculation depends on the adjugate 2024-12-28 10:29:43 +01:00
Sebastian Pahnke e8a202f0a2 Add tests for glsl and hlsl variants 2024-12-28 10:29:43 +01:00
Sebastian Pahnke 8a91e0bb19 Add regression tests reproducing the issue 2024-12-28 10:29:43 +01:00
Zoltán Kéri 490f527005 encoding/base32: Expand DEC_TABLE to full 256 bytes
The decoding table was only 224 bytes which caused type mismatches when
using custom alphabets, so expand with zeroes to cover full byte range
while maintaining the same decoding logic.
2024-12-26 19:20:46 +01:00
Zoltán Kéri 88c0e62095 encoding/base32: Use ENC_TBL parameter consistently in encode()
Fix encoding to properly use provided encoding table parameter instead of
hardcoded `ENC_TABLE`.

This makes encode properly support custom alphabets as documented.
2024-12-26 14:48:02 +01:00
Zoltán Kéri e7fb02a84a encoding/base32: Add custom validation support
Add support for custom alphabet validation through an optional validation
function parameter. The default validation follows RFC 4648 base32
alphabet rules (A-Z, 2-7).

This properly supports the documented ability to use custom alphabets.
2024-12-25 16:15:41 +01:00
Zoltán Kéri 8211a911db encoding/base32: Replace padding map with switch statement
Replace package-level map with a simple switch statement for padding
validation. This eliminates allocations we can't properly free while
maintaining the same validation logic.
2024-12-24 20:46:38 +01:00
Yawning Angel 3a5440e4ed base/runtime: Add ensure and ensure_contextless
This provides an equivalent to `assert` and `assert_contextless` that
are always evaluated, ignoring `ODIN_DISABLE_ASSERT`, which is useful
for enforcing API contracts or "asserting" on conditionals with
side-effects.
2024-12-25 00:08:09 +09:00
Zoltán Kéri e75a49f095 encoding/base32: Set optimization mode for decode() 2024-12-24 16:07:01 +01:00
Zoltán Kéri 93238db202 encoding/base32: Use consistent allocator and add proper cleanup
Fix memory handling throughout base32 package:
- Make padding map package-level constant (to avoid repeated allocs)
- Use passed allocator in encode's make() call
- Add defer delete for allocated memory in encode
- Add proper cleanup in test cases
- Fix memory cleanup of output buffers

The changes ensure consistent allocator usage and cleanup in both
implementation and tests.
2024-12-24 16:00:00 +01:00
Zoltán Kéri f1f2ed3194 encoding/base32: Fix decode implementation per RFC 4648
Rework base32.decode() to properly handle all cases per RFC 4648:

- Fix error detection order:
  - Check minimum length first (Invalid_Length)
  - Check character validity (Invalid_Character)
  - Check padding and structure (Malformed_Input)

- Fix padding validation:
  - Add required padding length checks (2=6, 4=4, 5=3, 7=1 chars)
  - Ensure padding only appears at end
  - Fix handling of unpadded inputs

- Fix buffer handling:
  - Proper output buffer size calculation
  - Add bounds checking for buffer access
  - Add proper buffer validation

For example:
- "M" correctly returns Invalid_Length (too short)
- "mzxq====" correctly returns Invalid_Character (lowercase)
- "MZXQ=" correctly returns Malformed_Input (wrong padding)
- Unpadded input lengths must be multiples of 8

These changes make the decode function fully compliant with RFC 4648
requirements while providing proper error handling.
2024-12-24 15:52:33 +01:00
Zoltán Kéri 7672ac945a encoding/base32: Add RFC 4648 test suite
Add test suite based on RFC 4648 test vectors and validation rules:
- Add section 10 test vectors for valid encoding/decoding
- Add test cases for invalid character handling (section 3.2)
- Add test cases for padding validation (section 4)
- Add test cases for length requirements (section 6)

The test vectors verify that:
- Empty string encodes/decodes correctly
- Standard cases like "foo" -> "MZXW6===" work
- Invalid characters are rejected
- Missing or malformed padding is detected
- Invalid lengths are caught
2024-12-24 15:28:34 +01:00
Zoltán Kéri b9338777e3 encoding/base32: Fix buffer allocation and bounds checking
Fix buffer allocation size calculation and add proper bounds checking to
ensure output buffer has sufficient space. This fixes crashes that could
occur with inputs like "AA" and other edge cases where the output buffer
was too small.

Remove #no_bounds_check as proper bounds checking is necessary for safe
error handling. The small performance trade-off is worth the improved
robustness.
2024-12-24 02:20:32 +01:00
Zoltán Kéri 8c761627c8 encoding/base32: Replace assertions with error returns
Replace assertions with proper error handling in base32.decode() to allow
programs to handle invalid input gracefully rather than crashing.

The function now returns ([]byte, Error) instead of just []byte.
2024-12-24 02:17:57 +01:00
Jeroen van Rijn ad99d20d29 Remove outdated PNG save helpers 2024-12-23 16:33:23 +01:00
dmitriy.gorevoy e82a0c8fc7 Fixed crash in arena_free_all() for bootstrapped growing arenas.
When trying to set arena.curr_block.used = 0 after mem.zero() caused a crash because if the arena is bootstrapped its memory will be zeroed out after mem.zero() thus making arena.cur_block point to zero.
2024-12-23 09:25:18 +01:00
fleandro 6ff81b6e4c make -export-dependencies:json emit valid json 2024-12-23 01:03:51 +00:00
Joao Fukuda 28e226381d Remove extra white space
Got in on 0a2200f without me noticing, mb.
2024-12-22 16:09:51 -03:00
Joao Fukuda 0a2200fa12 Fix issue #4612 2024-12-22 15:53:54 -03:00
Misomosi 276dab69b6 Pack MDEI struct to fix issue #4407 2024-12-22 10:12:10 -05:00
misomosi fdf510b7b3 Pack struct when needed, use field_align metadata 2024-12-22 10:05:13 -05:00
blob1807 f07a6f463c Fix io.write_escaped_rune not writing full value 2024-12-22 23:10:42 +10:00
Roland Kovacs 9f77f7c417 Fix crash on assignment of parapoly proc to variable 2024-12-22 12:38:37 +01:00
Roland Kovacs f2f952b344 Fix crash when proc return type is undeclared parapoly variable
Disallow the declaration of new parapoly variables in return types, when
the procedure's parapoly scope is itself. This happens if e.g.:
`foo :: proc() -> $T`.

Closes #3949, #4294, #4563
2024-12-22 02:31:25 +01:00
misomosi 26f9688c69 Fix early overwrite of dst w/ exp_u64 2024-12-21 16:53:31 -05:00
avanspector a20d85df1e Fix os_haiku.odin (again) 2024-12-21 17:15:53 +01:00
avanspector 365e24ce8d Remove error baselines from Errno to make fmt clearer 2024-12-21 17:09:57 +01:00
avanspector cb42b88e13 Update errno.odin 2024-12-21 16:54:45 +01:00
Karl Zylinski e5f32e1455 Makes tracking allocator default to crashing on a bad free instead of add to bad_free_array. The bad_free_array remains to not break old code. The new default behavior is implemented in a callback that you can override, there's a second provided callback that provides the old behavior where an element was added to bad_free_array. Rationale: Many people are just checking the allocation_map, but don't check the bad free array. Several examples throughout core that use tracking allocator don't check bad_free_array either, so people have been taught not to check it. 2024-12-21 15:49:48 +01:00
chris-montero c06f79bb36 fixed memory leak in core/prof/spall/doc.odin example code 2024-12-21 15:53:55 +02:00
avanspector be4748831d Delete errors.odin 2024-12-20 17:25:15 +01:00
avanspector 5376d2a20b fix haiku 2024-12-20 17:19:04 +01:00
Barinzaya 14216ebf51 Added some implicit broadcasting for #simd arrays.
This covers broadcasting from untyped numbers when assigning, as well as
when performing binary operations. SIMD intrinsics have not been
adjusted
2024-12-19 20:07:04 -05:00
Barinzaya 5f46b5ca50 Fixed zeroing in resize_dynamic_array.
When a dynamic array has unused capacity and is resized to a size
greater than its capacity, the unused part of its capacity wasn't being
zeroed.
2024-12-19 17:52:09 -05:00
jason b73275cf42 Get arm64 up to speed in os2 linux
Readded open flags for arm64 to sys/linux/bits.odin. Make process_start
name based instead of descriptor based to allow running of scripts. Fix
bug in heap_linux. Fix and simplify os2.remove.
2024-12-19 17:12:07 -05:00
gingerBill 597fba7c31 Merge pull request #4597 from lodinukal/master
`vendor:directx`: fix pointers to multipointers and uuids
2024-12-19 13:36:36 +00:00
imlodinu cce2cb79c9 Change single pointers to multipointers, fix UUIDs in d3d11 and d3d12 2024-12-19 12:23:00 +08:00
gingerBill 61368d942e Merge pull request #4589 from Pariatech/add-trunc-to-linalg-glsl
Add trunc to glsl linalg
2024-12-18 21:20:17 +00:00
Jeroen van Rijn d3f072835d Merge pull request #4592 from cstrachan88/master
Fixes odin-lang/Odin#4591
2024-12-17 21:23:49 +01:00
Courtney Strachan 69bbd8082a Fixed typo in wgpu.js 2024-12-17 12:13:48 -08:00
Gabriel Pariat e0b7bfd21e add trunc to glsl linalg 2024-12-17 13:06:59 -05:00
wrapperup f761dc2102 cleanup redundant constants 2024-12-16 22:58:12 -05:00
wrapperup 6753946b7a fix resource_manager_flag enum 2024-12-16 22:12:20 -05:00
wrapperup c64f13a0eb use bit sets in miniaudio for flags 2024-12-16 18:34:22 -05:00
ed aa8bc79d34 update gen_src.cpp 2024-12-15 10:35:10 -05:00
ed 94b1acf2b6 update gencpp once again to latest.. 2024-12-15 10:14:30 -05:00
Laytan 8b1c9b0ff5 Merge pull request #4568 from giuliano-macedo/master
docs: improved `slice.reinterpret` docstring
2024-12-14 16:46:17 +01:00
Giuliano Macedo 6785a485e3 docs: improved reinterpret docstring 2024-12-14 10:10:06 -03:00
ed ddbd50a098 correct gen_src.cpp to latest gencpp 2024-12-14 07:14:02 -05:00
ed 31c3e48236 update gencpp to latest 2024-12-14 07:12:35 -05:00
ed 2c66a62d55 gencpp: fix for <= operator deduction 2024-12-13 11:55:31 -05:00
ed ad813d0335 update gencpp to latest and adjsut gen_src.pp accordingly. 2024-12-13 11:50:40 -05:00
ed daa820b134 Merge tag 'dev-2024-12'
# Conflicts:
#	vendor/raylib/windows/raylib.dll
#	vendor/raylib/windows/raylibdll.lib
2024-12-13 09:36:58 -05:00
gingerBill 0a29d36aa3 Fix bug with comparisons with big endian types 2024-12-12 15:44:49 +00:00
Laytan cecd7ea0b2 Merge pull request #4572 from GonkieDev/win32_rawinput_typo_fix
Typo in windows rawinput constant's name
2024-12-11 23:02:25 +01:00
GonkieDev 6bcfafc3a8 typo fixed (MOUSE_ATTRIUBTTES_CHANGED -> MOUSE_ATTRIBUTES_CHANGED) 2024-12-11 21:02:43 +00:00
gingerBill db1b67daba Merge pull request #4558 from thebigtoona/vendor/raylib-add-rcamera-module-bindings
add bindings for rCamera module in vendor/raylib/raylib.odin
2024-12-11 12:32:55 +00:00
gingerBill 954adef2d4 Merge pull request #4570 from laytan/remove-viral-inlining
compiler: remove viral `#force(_no)_inline`
2024-12-11 12:32:47 +00:00
Laytan Laats c8f0d27cee compiler: remove viral #force(_no)_inline
If a procedure was marked `#force_no_inline`, any procedure calls within
it would also implicitly be. This is not expected for multiple reasons:

1. `#force(_no)_inline` on a call expr works differently than on a procedure literal.
2. Adding the attribute on it and every called proc blows up the amount
   of work for the inliner pass and may increase the time it takes.
3. Putting `#force_no_inline` on a procedure to keep executable size
   down (like we do for some map procedures), benchmark it, or find it in
   asm/ir has the added effect of slowing those procedures down significantly
   and not representing truth.
2024-12-09 19:12:42 +01:00
gingerBill 67720e3a9d Merge pull request #4567 from 2nafish117/dxgi-multipointer-usage
change pointer arg to multipointer in GetDisplayModeList and GetDisplayModeList1
2024-12-09 17:10:06 +00:00
shashank d02f575561 change pointer arg to multipointer in GetDisplayModeList and GetDisplayModeList1 2024-12-08 21:41:01 +05:30
gingerBill f28fa736b3 Merge pull request #4551 from wrapperup/vulkan-1.4.303
`vendor:vulkan` Update bindings version to 1.4.303
2024-12-08 13:11:13 +00:00
wrapperup 59d88f2a22 add missing vulkan video constants 2024-12-07 20:48:14 -05:00
Laytan Laats 6e1d028861 fix #4389 - retrieve file type by opening if other methods failed 2024-12-06 23:51:14 +01:00
Laytan Laats f1cae8d844 fix #4496 - allow unlock of unlocked mutex (making it consistent with windows behaviour) 2024-12-06 23:08:47 +01:00
Laytan Laats 7edd332993 fix #4536 - stack buffer overflow for size_of 0 types in struct unmarshal 2024-12-06 22:12:52 +01:00
Laytan Laats 676fe34863 fix #4547 - wasm -out without file extension 2024-12-06 19:38:53 +01:00
Laytan Laats 402f8dd576 raylib/rlgl: fix foreign imports after update to 5.5 2024-12-06 18:54:48 +01:00
gingerBill 7be0035578 Merge pull request #4560 from gfaster/which-nix-shell
add which to shell.nix to build with --pure
2024-12-06 14:21:16 +00:00
gingerBill e4bdc4ff7c Merge pull request #4562 from dozn/patch-1
Move Struct Field Zipping Outside of Loop
2024-12-06 14:21:01 +00:00
gingerBill 62768ad857 Merge pull request #4564 from gfaster/4553-regression-test
Add regression test for #4553
2024-12-06 14:20:51 +00:00
Gavin 25ae3d0785 Add regression test for #4553
This test is definitely imperfect (should have no erroneous failures,
only erroneous passes), but should serve as a good smoke test
if matrix alignment is ever broken again. Looking at the generated LLVM,
there is a bunch of weird choices for alignment chosen that might be
worth looking into.

It's also worth noting that the failure mode of this test is a #GP
exception, which I don't know how well the test runner handles in a
larger test corpus.
2024-12-05 15:26:18 -05:00
Laytan Laats cf53404f5f sync: fix no new values 2024-12-05 20:05:19 +01:00
Laytan Laats ac3a87c2cf sync: fix require results 2024-12-05 19:04:45 +01:00
Laytan Laats ad438f418d sync: fix futexes on wasm 2024-12-05 19:00:45 +01:00
gingerBill d452d37b93 Fix #4537 2024-12-05 15:51:05 +00:00
gingerBill e3b1646490 Fix #4552 2024-12-05 15:46:35 +00:00
gingerBill dd8e6e884c Try to fix #4553 2024-12-05 15:45:01 +00:00
gingerBill f5b16aa42a Fix #4561 2024-12-05 15:27:41 +00:00
dozn 37fb2754a1 Move Struct Field Zipping Outside of JSON Token Loop 2024-12-05 07:23:34 -08:00
gingerBill f7761ebcc4 Make odin.rc terser 2024-12-05 12:30:55 +00:00
gingerBill a4b071e864 Add /nologo 2024-12-05 12:30:17 +00:00
gingerBill b36a81ef53 ABI change: for indirect parameters size_of <= 16, do callee stack copy 2024-12-05 10:49:39 +00:00
Tina Colvin 52a7a3e5fc change camera defines to constants 2024-12-04 16:44:00 -07:00
Gavin 96691c364b add which to shell.nix to build with --pure 2024-12-04 18:10:19 -05:00
Laytan cdb86d69b3 Merge pull request #4556 from cornishon/index_multi
improve `strings.index_multi`
2024-12-04 22:01:49 +01:00
Adam Zadrożny ce51b79a37 Fix the unused variable errors 2024-12-04 21:09:47 +01:00
Tina Colvin dc0e189e32 add bindings for rCamera module in vendor/raylib/raylib.odin 2024-12-04 11:49:24 -07:00
Adam Zadrożny 5dfc24882f improve strings.index_multi
There's no point searching for substrings after lowest_index,
so let's not.

This significantly improves performance on long strings.
2024-12-04 14:29:49 +01:00
gingerBill c79466ab3c Merge pull request #4548 from Bazzas-Forks/linalg-clamp-length
[core:math/linalg] Add `linalg.clamp_length(vector, max_length) -> clamped_vector`
2024-12-04 12:05:06 +00:00
flysand7 49b8abe3ef Apply suggestions from code review
Co-authored-by: Laytan <laytanlaats@hotmail.com>
2024-12-04 22:50:10 +11:00
Laytan 910b46ebf0 Merge pull request #4555 from ycros/fix-regex-num-groups
fix: regex's match_with_preallocated_capture returning num_groups
2024-12-04 12:46:57 +01:00
flysand7 ba6224b61a Apply suggestions from code review
Co-authored-by: Laytan <laytanlaats@hotmail.com>
2024-12-04 19:11:21 +11:00
Ycros bf63e9b093 Add test for regex preallocated captures. 2024-12-04 14:38:07 +11:00
Ycros 7edc46f1b9 fix: regex's match_with_preallocated_capture returning num_groups 2024-12-04 13:51:27 +11:00
Jeroen van Rijn 04e8dcc042 Merge pull request #4554 from Kelimion/get-date
Add misc\get-date.c
2024-12-03 12:49:33 +01:00
Jeroen van Rijn ef5546aea5 Add misc\get-date.c
Prints the current date as YYYYMMDD without relying on PowerShell.

Hopefully fixes #4540
2024-12-03 12:42:13 +01:00
wrapperup 08f14db8e8 regenerate vulkan vendor bindings (1.4.303) 2024-12-02 17:48:32 -05:00
gingerBill b942479886 Minor improvement to type handing on failures 2024-12-02 15:57:20 +00:00
gingerBill 65de0256ce Fix #4535 2024-12-02 15:57:08 +00:00
gingerBill af8122e8c7 Merge pull request #4541 from Waqar144/work/thread-pool-use-queue
Use a proper Queue in thread.Pool
2024-12-02 12:04:28 +00:00
gingerBill 7d5ac2a164 Merge branch 'master' of https://github.com/odin-lang/Odin 2024-12-02 11:24:00 +00:00
gingerBill e2ba8ff6e6 Fix #4530 2024-12-02 11:23:55 +00:00
gingerBill 1a84820e83 Merge pull request #4542 from FourteenBrush/master
Pass allocator to implicitly (de)allocating procs in `core:log`
2024-12-02 10:55:09 +00:00
gingerBill d0f87913e2 Fix #4549 2024-12-02 10:49:49 +00:00
Bazzagibbs 4b76568596 Add linalg.clamp_length(vector, max_length) -> clamped_vector 2024-12-02 11:58:36 +11:00
Laytan 03a53ccce2 Merge pull request #4546 from thetarnav/correct-parsing-build-tag-newlines
Correct handling newlines between build tags in `core:odin`
2024-12-01 19:13:59 +01:00
Damian Tarnawski 26415bcb0e Correct handling newlines between build tags in core:odin
Previously I thought that each newline worked as `OR`
basically the same as `,`.

This corrects this to work as `AND` instead.
2024-12-01 18:21:26 +01:00
flysand7 8387561d0a [core/simd]: Write package documentation 2024-12-02 01:24:33 +11:00
Laytan Laats e6a9f93e9f dynlib: unload library before loading again & add LIBRARY_FILE_EXTENSION constant 2024-12-01 11:54:56 +11:00
Jeroen van Rijn 47888794c8 Fix assert when return value expected. 2024-12-01 11:54:56 +11:00
Jeroen van Rijn ad8bff4d3a Make O_RDONLY default for os.open on all platforms.
And also moved Windows file procs to `os_windows.odin`, in line with all the other platforms who didn't have a dedicated `file_<platform>.odin`
2024-12-01 11:54:56 +11:00
Evan Martinez 486a650630 Fix binomial function 2024-12-01 11:54:56 +11:00
0dminnimda 79733c5f5e src/main.cpp: apply suggestion
Co-authored-by: Laytan <laytanlaats@hotmail.com>
2024-12-01 11:54:56 +11:00
0dminnimda 27aa40c357 Update version in more places 2024-12-01 11:54:56 +11:00
0dminnimda 496b676f12 Fix a mistake in build_odin.sh 2024-12-01 11:54:56 +11:00
0dminnimda 456279feba Add support for llvm version 19 2024-12-01 11:54:56 +11:00
Laytan Laats d51692a3b4 properly keep track of current scope for debugging
Fixes #4519
2024-12-01 11:54:56 +11:00
zhylmzr 2bd6fc9ebd fix DNS_RECORD.Data error align on windows i386
fixed: https://github.com/odin-lang/Odin/issues/4520
2024-12-01 11:54:56 +11:00
Jeroen van Rijn 21ff9856d4 Check type_expr in check_procedure_param_polymorphic_type
Fixes #4523 assert.
2024-12-01 11:54:56 +11:00
Andreas T Jonsson c572c80a64 Updated NetBSD CI to pkgsrc Q3 release 2024-12-01 11:54:56 +11:00
Laytan Laats da4347f790 sys/info & odin report: rework macos version retrieval 2024-12-01 11:54:56 +11:00
Laytan Laats 76516030c4 vendor/raylib: revert removal of arm64 raygui binaries and fix import paths 2024-12-01 11:54:56 +11:00
Laytan Laats 5a201d588b add macos 15.1.1 to odin report and sys/info 2024-12-01 11:54:56 +11:00
gingerBill 1be9833073 Convert mutex guard to "try lock" 2024-12-01 11:54:56 +11:00
Jeroen van Rijn 9388f0d5a5 Add aliases for Is*Ready -> Is*Valid 2024-12-01 11:54:56 +11:00
Jeroen van Rijn 0e3572947a Fix #4508 for abs, min, max (#4516)
* Fix #4508 for abs, min, max and the rest of the builtins.

None of these segfault now:
```odin
package bug

main :: proc() {
	p :: proc() {}

	// _ = len(p())
	// _ = cap(p())

	// _ = size_of(p())
	// _ = align_of(p())

	// T :: struct {}
	// _ = offset_of(p())
	// _ = offset_of(T, p())
	// _ = offset_of(p(), foo)
	// _ = offset_of(p(), "")

	// _ = type_of(p())
	// _ = type_info_of(p())
	// _ = typeid_of(p())

	// A: [4]int
	// _ = swizzle(p())    //  :: proc(x: [N]T, indices: ..int) -> [len(indices)]T ---
	// _ = swizzle(A, p()) //  :: proc(x: [N]T, indices: ..int) -> [len(indices)]T ---

	// _ = complex(p(), p())
	// _ = quaternion(p(), p(), p(), p())
	// _ = quaternion(w=p(), x=p(), y=p(), z=p())

	// _ = real(p())
	// _ = imag(p())
	// _ = jmag(p())
	// _ = kmag(p())
	// _ = conj(p())

	// _ = expand_values(p())

	// _ = min(p())
	// _ = max(p())
	// _ = abs(p())
	// _ = clamp(p(), p(), p())

	// _ = soa_zip(p())
	// _ = soa_unzip(p())
}
```
2024-12-01 11:54:56 +11:00
gingerBill 3c3c59fc03 Allow for odin help build etc 2024-12-01 11:54:56 +11:00
Jeroen van Rijn 7e4aafe239 Add comment explaining #4515 test. 2024-12-01 11:54:56 +11:00
Jeroen van Rijn 66c57e380a Test #4515 2024-12-01 11:54:56 +11:00
o:tone d15d152746 fix unmarshal unhandled error (#4515)
* fix unmarshal unhandled error
2024-12-01 11:54:55 +11:00
lxmcf 0f7b1b426f Resolve indentation issues 2024-12-01 11:54:55 +11:00
Alex Macafee 58d08090f7 Add missing trailing commas 2024-12-01 11:54:55 +11:00
lxmcf 9f1e3862b5 Update vendor:raylib to raylib 5.5 2024-12-01 11:54:55 +11:00
gingerBill 329855e586 Delete imports of removed packages 2024-12-01 11:54:54 +11:00
gingerBill d85de2e54e Remove core:c/frontend 2024-12-01 11:54:54 +11:00
Jeroen van Rijn 4d9a9ec3f5 Fix #4509 2024-12-01 11:54:54 +11:00
Laytan Laats 1d8eb3aac4 checker: only error with -vet-cast when it is actually castable 2024-12-01 11:54:54 +11:00
Colin Davidson 876989b3ab oops, copy-paste-bug 2024-12-01 11:54:54 +11:00
Colin Davidson 6c140b01ed oops 2024-12-01 11:54:54 +11:00
Colin Davidson b66e756135 fix parsing issue around utc/localtime split 2024-12-01 11:54:54 +11:00
gingerBill 514b537dd5 Improve odin help -foo usage 2024-12-01 11:54:54 +11:00
Waqar Ahmed 3f30953c01 Fix typo, its supposed to be #config
Otherwise compile errors out when importing the file with the error:

```odin
vendor/lua/5.2/lua.odin(10:15) Error: Undeclared name: config 
        LUA_SHARED :: config(LUA_SHARED, false) 
```
2024-12-01 11:54:54 +11:00
gingerBill 6baff9f1f8 Update radlink.exe 2024-12-01 11:54:54 +11:00
jakubtomsu a119a6f33e Fix a bug in hxa decoder found by the new check 2024-12-01 11:54:54 +11:00
jakubtomsu aaea7b27f2 report error when builtin min/max has 1 (non-type) param 2024-12-01 11:54:54 +11:00
Dudejoe870 76d689a601 Fix typo in Quaternion dot product 2024-12-01 11:54:54 +11:00
Laytan Laats 460e2629bd sys/posix: add MAP_ANONYMOUS 2024-12-01 11:54:54 +11:00
Laytan Laats 468c0b573a add missing macos version 2024-12-01 11:54:54 +11:00
Tetralux f8003b8b03 [runtime] make(map[K]V) should not allocate any capacity
`make(map[K]V)` was resolving to `make_map_cap()` which allocates initial capacity when it wasn't intended to.
It now calls `make_map()` which doesn't allocate any capacity.

Both `make(map[K]V)` and `make(map[K]V, allocator)` will NOT allocate initial capacity now.
2024-12-01 11:54:54 +11:00
Laytan Laats ed8aede369 os2: skip dir test when unsupported 2024-12-01 11:54:54 +11:00
Laytan Laats d94ef8d27a sys/posix: fix dirfd on netbsd 2024-12-01 11:54:54 +11:00
Laytan Laats ac2c9ac713 os2: fix file type detection in dir_windows 2024-12-01 11:54:54 +11:00
Laytan Laats dac927fb75 os2: add read dir test 2024-12-01 11:54:54 +11:00
Laytan Laats 0c64129aad os2: fix leak in dir_windows 2024-12-01 11:54:54 +11:00
NicknEma f8ba86e0a6 Fix integer type
Change int to i32 so it is the correct size
2024-12-01 11:54:54 +11:00
gingerBill 57e0c41982 Make lowercase 2024-12-01 11:54:54 +11:00
gingerBill d613a9ee5a Fix typo 2024-12-01 11:54:54 +11:00
gingerBill e58ac3cb8d Add -linker:<string> to replace -lld and -radlink 2024-12-01 11:54:54 +11:00
gingerBill 6963b0f3f2 Check for more errors in json.unmarshal 2024-12-01 11:54:54 +11:00
gingerBill 95731aceac Disallow -lld and -radlink to be used together 2024-12-01 11:54:54 +11:00
A1029384756 9e520c38db core:sys/linux - prefixing + moved IN_CLOSE/IN_MOVE to constants 2024-12-01 11:54:54 +11:00
A1029384756 59adcf6c46 core:sys/linux - flags, spacing, inotify_init 2024-12-01 11:54:54 +11:00
A1029384756 f6b0ea160b core:sys/linux - fixed vet errors 2024-12-01 11:54:54 +11:00
A1029384756 be66d4bd8b core:sys/linux - implemented inotify
core:sys/linux - added constants and spacing
2024-12-01 11:54:53 +11:00
gingerBill 3afde70513 Add radlink.exe 2024-12-01 11:54:53 +11:00
gingerBill ec96939953 Add -radlink 2024-12-01 11:54:53 +11:00
gingerBill 5d38eb9d81 Remove relative types from json marshaller 2024-12-01 11:54:53 +11:00
Alex Overstreet 357d6212d0 Use tabs instead of spaces 2024-12-01 11:54:53 +11:00
Alex Overstreet 522f05445e Add STICKYKEYS, TOGGLEKEYS, and FILTERKEYS 2024-12-01 11:54:53 +11:00
Sebastian Pahnke a0561860f9 Add NSApplication bindings for mainWindow and keyWindow 2024-12-01 11:54:53 +11:00
gingerBill e72736a5a8 Remove #relative types from the compiler 2024-12-01 11:54:53 +11:00
gingerBill 31c630dfea Make #relative types an error in parsing 2024-12-01 11:54:53 +11:00
gingerBill 95c812db78 Keep ASAN happy on type assertions 2024-12-01 11:54:53 +11:00
p2jason 62d30daa00 Increase size of JS keyboard event key/code buffer size 2024-12-01 11:54:53 +11:00
Laytan Laats 38c79b203a reflect: add enum_value_has_name proc
Easy way to check if the current value has a defined name/member in the
enum type.
2024-12-01 11:54:53 +11:00
Satoshi Soma 362086d5d2 Fix: build_odin.sh always runs demo regardless of argument
Instead, it should run demo only if the argument was 'debug' or empty
2024-12-01 11:54:53 +11:00
Bazzagibbs 25be3dfca0 Add core:slice.size to get the byte size of a slice's backing data 2024-12-01 11:54:53 +11:00
bayo-code 7bd49cf018 Added support for odin build -target:? 2024-12-01 11:54:53 +11:00
bayo-code 9fbde3c1b8 Revert "List the supported targets using odin targets"
This reverts commit b589e3c499.
2024-12-01 11:54:53 +11:00
bayo-code c73c438db9 List the supported targets using odin targets 2024-12-01 11:54:53 +11:00
Doeke Wartena bbb1400349 Update demo.odin
type: turns -> returns
2024-12-01 11:54:53 +11:00
Jacob Pfeiffer a8d603fd7d Correct zlib usage in doc 2024-12-01 11:54:53 +11:00
AP Darkly f56cc069c5 fix relative links in examples/README.md
This fix adjusts the links for 'demo', 'core', 'all', and 'vendor' so that they navigate to the intended destinations instead of yielding 404s.
2024-12-01 11:54:53 +11:00
Doeke Wartena cc1c97c6d0 Update scanner.odin
remove duplicated wording in comment
2024-12-01 11:54:53 +11:00
gingerBill ddca55165d Remove duplicates in -defineables 2024-12-01 11:54:53 +11:00
A1029384756 943b09a8b1 added unlinking section to posix socket binding documentation 2024-12-01 11:54:53 +11:00
Jeroen van Rijn 826abd6245 && 2024-12-01 11:54:53 +11:00
Jeroen van Rijn d44f8c377a Phrasing! 2024-12-01 11:54:53 +11:00
Jeroen van Rijn 9ecc378803 Suggest -microarch:native if popcnt instruction is missing.
Fixes #4453.
2024-12-01 11:54:53 +11:00
nickk-dv 1e600d74f1 fix LoadRandomSequence binding in vendor raylib 2024-12-01 11:54:53 +11:00
Morten Hauke Solvang 6c750c6670 Suggestion when assigning enum to bit_set 2024-12-01 11:54:53 +11:00
Dominik Pötzschke a71832570c added braces 2024-12-01 11:54:53 +11:00
Dominik Pötzschke f37ec05548 adjust memory allocation 2024-12-01 11:54:52 +11:00
Dominik Pötzschke 841996435b fix: fix windows params bug 2024-12-01 11:54:52 +11:00
gingerBill 11768c6217 Minor formatting change 2024-12-01 11:54:52 +11:00
Colin Davidson 514faa517e oops, missed a comma 2024-12-01 11:54:52 +11:00
Colin Davidson 3b4338b685 add new test, better fail-check, and non-transitioning tz fix 2024-12-01 11:54:52 +11:00
0dminnimda 24ec0f0ebf Revert further simplifiction 2024-12-01 11:54:52 +11:00
0dminnimda a7f32109e8 Simplify further 2024-12-01 11:54:52 +11:00
0dminnimda 4f37b34654 Simplify use of pie 2024-12-01 11:54:52 +11:00
0dminnimda 480f32586e Add support for linking as pie 2024-12-01 11:54:52 +11:00
gingerBill 619b382635 Fix previous commit for arrays 2024-12-01 11:54:52 +11:00
gingerBill 50e46326a6 Fix bug for foo().bar where foo() is a 0-value expression 2024-12-01 11:54:52 +11:00
gingerBill fafac1bc77 Fix auto_cast matrix bug 2024-12-01 11:54:52 +11:00
gingerBill d5b6c25686 Fix #4406 os2 to not close the std file handles but rather just free the memory for the ^File data. 2024-12-01 11:54:52 +11:00
NicknEma 1b7a32f76c Mark procs as "contextless" in winerror.odin
So that they can be called from places like the windproc and stuff.
2024-12-01 11:54:52 +11:00
Jeroen van Rijn 1a13322cd7 Missing paren. 2024-12-01 11:54:52 +11:00
Jeroen van Rijn c5d3fdca44 mem.is_aligned is in bytes, not log2 bytes
Fix formula and clarify comment
2024-12-01 11:54:52 +11:00
p2jason ee84aa4ead Removed event hook callback from add_*_event_listener functions 2024-12-01 11:54:52 +11:00
p2jason f993fcb82c Removed event queue from add_*_event_listener JS functions and added event hook callback 2024-12-01 11:54:52 +11:00
p2jason aa08f661ca Changed boolean parameters to bit set in the add_*_event_listener functions 2024-12-01 11:54:52 +11:00
p2jason 0eac9f15bc Added parameters to the add_*_event_listener JS functions for stopping event behavior 2024-12-01 11:54:52 +11:00
Laytan Laats 9adc7f2bcf fix tabs 2024-12-01 11:54:52 +11:00
Laytan Laats 6866e69cb9 add time/timezone to docs 2024-12-01 11:54:52 +11:00
Laytan Laats 9735f8a0ba add CoreFoundation and Security to docs 2024-12-01 11:54:52 +11:00
Laytan Laats 7b63abdba3 add kqueue to docs 2024-12-01 11:54:52 +11:00
Laytan Laats e6d324c5c4 testing: separate the posix import into target files
This is needed for the docs generator to generate all the docs for the
posix package, if it is imported like it was on Windows it would
generate docs for the Windows version of the package which has much less
symbols exposed.
2024-12-01 11:54:52 +11:00
Barinzaya 6fa646cbf1 Fixed raymath not applying matrix translations.
Translation matrices use the w components of the matrix to apply the
transform, and thus only work when the w component is 1. In the
original raymath implementation, the multiplication is done manually
and adds the translation components directly to the result, as if w is
1, but in the Odin binding this is done with a matrix multiplication.
However, the w component is set to 0 instead of 1, resulting in the
translation not being applied.
2024-12-01 11:54:52 +11:00
peachey2k2 186499c8af Add "-build-mode:dynamic" to the "odin help build" output 2024-12-01 11:54:52 +11:00
Laytan Laats c08408ea08 fix thread_unix for Darwin after pthread corrections in posix package
afed3ce removed the sys/unix package and moved over to sys/posix, it has
new bindings for the pthread APIs but should have been equivalent (not).

8fb7182 used `CANCEL_ENABLE :: 0`, `CANCEL_DISABLE :: 1`, `CANCEL_DEFERRED :: 0`, `CANCEL_ASYNCHRONOUS :: 1` for Darwin, while the
correct values are `1`, `0`, `2` and `0` respectively (same mistake was made for
FreeBSD in that commit).

What this meant is that the
`pthread_setcanceltype(PTHREAD_CANCEL_ASYNCHRONOUS)` was not actually
successful, but because the error wasn't checked it was assumed it was.
It also meant `pthread_setcancelstate(PTHREAD_CANCEL_ENABLE)` would
actually be setting `PTHREAD_CANCEL_DISABLE`.

The code in this PR restores the behaviour by now actually deliberately
setting `PTHREAD_CANCEL_DISABLE` and not setting
`PTHREAD_CANCEL_ASYNCHRONOUS` which was the previous behaviour that does
actually seem to work for some reason.

(I also fixed an issue in fmt where `x` would use uppercase if it was a
pointer.)
2024-12-01 11:54:52 +11:00
bobsayshilol 96e6393614 Plug a memory leak
The call to |array_make()| always allocates and since this variable was
unused it lead to a leak. Simply plug it by removing it.
2024-12-01 11:54:52 +11:00
bobsayshilol 73b6461710 Add missing guards around push/pop pragmas
This matches all the other places where we silence Windows warnings.
2024-12-01 11:54:52 +11:00
bobsayshilol 56094f3580 Fix passing nullptr to args marked as non-null
libstdc++'s |memcpy| and |memset| both state that their inputs should
never be a nullptr since this matches the C spec. Some compilers act on
these hints, so we shouldn't unconditionally call these as it would
signal to the compiler that they can't be nullptrs.

As an example, the following code will always call |do_something()|
when compiled with optimisations since GCC version 4.9:
```
    void clear(void *ptr, int size) {
        memset(ptr, 0, size);
    }
    void example(void *ptr, int size) {
        clear(ptr, size);
        if (ptr != nullptr) do_something();
    }
```
2024-12-01 11:54:52 +11:00
bobsayshilol 30fb2ed59d Avoid undefined arithmetic shifting
The result of a left shift on a positive signed integer (Rune) must fit
into an unsigned integer otherwise it's undefined behaviour, as is left
shifting a negative integer by any amount. This code can only be hit if
|x >= 0xf0| and hence a left shift of 31 will always be undefined
unless the input is 0 or 1.

To avoid hitting this we can instead extend the lowest bit to be the
mask if we assume that ints are 2's complement, which we already do
elsewhere. This generates identical code in testing on Compiler
Explorer and the Odin test suite passes locally with this change.

Note that the original code would change to be defined behaviour in
C++20, however we are currently build with |-std=c++14| in the build
scripts.
2024-12-01 11:54:51 +11:00
bobsayshilol ddde456af7 Avoid member access through nullptr in debug
If |result_count| is 0 then |results| will be a nullptr and hence the
access |results->Tuple| is undefined behaviour. There's already an
early return in the 0 branch so move that to be the first thing so that
we can guarantee that it's not a nullptr.

Note that technically we take the address of the result so it's not
actually dereferencing it, however UBSan doesn't care about that.
2024-12-01 11:54:51 +11:00
bobsayshilol b10538da7a Fix invalid union access
UBSan spotted that |src->Basic.kind| had a value outside the range of
|BasicKind| due to it actually being a |Type_Pointer|. Since these are
stored in a union there could be cases where the value of |kind| just
so happens to be |Basic_string|, in which case the branch would have
been taken when it shouldn't have been.

To fix this simply check that it's a |Type_Basic| before treating it as
a |Basic|.
2024-12-01 11:54:51 +11:00
Laytan 78dc4d4907 fix test 2024-12-01 11:54:51 +11:00
Laytan 9f1c894f1f port pthread_mutex_t and pthread_cond_t from sys/unix cause miniaudio wants it 2024-12-01 11:54:51 +11:00
Laytan f342215b4d clean up dynlib and path/filepath with sys/posix 2024-12-01 11:54:51 +11:00
Laytan 2b5f0fc729 remove pthread from sys/unix and use sys/posix where used 2024-12-01 11:54:51 +11:00
Laytan 7de56ec852 fix #load_directory including nested directories 2024-12-01 11:54:51 +11:00
Laytan Laats 49ddbd9b99 sys/posix: impl rest of linux, impl some of Windows 2024-12-01 11:54:51 +11:00
Karl Zylinski 879771fe32 Fix for using utf8string.at with last rune index returning wrong rune. 2024-12-01 11:54:51 +11:00
Jeroen van Rijn c9c237babf match_exact_value: return when type is compound
fixes #4431
2024-12-01 11:54:51 +11:00
Alexis Caraballo d9326ae93d fix cbor.to_json always returning array of tuples for objects
to_json uses a small proc to check if all keys of an object are strings.
It was always returning false for any input.
2024-12-01 11:54:51 +11:00
Jeroen van Rijn 1df246664f Fix image.which_bytes
Invert test in `which_bytes` to fix Softimage PIC detection. Fixes #4429.
2024-12-01 11:54:51 +11:00
Laytan 5faefac106 math/rand: choice_bit_set return not_empty -> ok 2024-12-01 11:54:51 +11:00
Laytan Laats d85f18e898 math/rand: add choice_bit_set 2024-12-01 11:54:51 +11:00
Patric Dexheimer 12cfc9b8de Update process_windows.odin
Mistype
2024-12-01 11:54:51 +11:00
IllusionMan1212 fafb2b1e75 core/io: correctly escape runes greater than 0xFFFF 2024-12-01 11:54:51 +11:00
Yawning Angel 111f10cbbf src/big_int.cpp: Use square-multiply for exponentiation
For utterly unrealistic constant sizes, this still crashes on my system,
but it crashes fast due to the OOM killer, and people using rediculously
large exponents get what they deserve.
2024-12-01 11:54:51 +11:00
gingerBill 197339d91d Add warning for unsigned >= 0 like conditions in a for loop 2024-12-01 11:54:51 +11:00
gingerBill e6a4f3048f Fix possible leak in recursive filepath.glob 2024-12-01 11:54:51 +11:00
gingerBill 63f880ae80 Fix bug caused due to incorrect type checking looking for context not defined in a context 2024-12-01 11:54:51 +11:00
Laytan Laats 8e6cbe9a29 fix the typeid type kind of a typeid being set to Typeid_Invalid 2024-12-01 11:54:51 +11:00
Laytan Laats f3c19e183f wgpu: add missing JS impl for RenderPassEncoderSetBlendConstant 2024-12-01 11:54:51 +11:00
Laytan Laats d185ab5991 sys/wasm/js: add set_element_style 2024-12-01 11:54:51 +11:00
Laytan Laats 3740497e42 encoding/cbor: fix skipping of ignored/missing fields in struct unmarshal 2024-12-01 11:54:51 +11:00
Laytan Laats 4207d4fded encoding/cbor: handle binary having more fields than the struct by discarding 2024-12-01 11:54:51 +11:00
Laytan Laats 0d4d3bd1de math/rand: support non-contiguous enums in choice_enum 2024-12-01 11:54:51 +11:00
Laytan Laats 538cea27f7 wgpu: take version check out of @init, use C cc when appropriate 2024-12-01 11:54:51 +11:00
Laytan Laats 0c470895b3 image: add panic when load is called without any registered loaders 2024-12-01 11:54:50 +11:00
Laytan Laats 6e534c0e24 check packed load and set alignment on all loads, not just lb_emit_load 2024-12-01 11:54:50 +11:00
Laytan Laats 64fdf6e18f quote the dsymutil argument
Fixes #4417
2024-12-01 11:54:50 +11:00
Lucas Perlind fc3ea5b3d9 core/unicode/utf16: add rune_count proc
This returns the number of runes in a u16 slice
2024-12-01 11:54:50 +11:00
Misomosi f1667422e6 Fix #4390 by assigning invalid entity type 2024-12-01 11:54:50 +11:00
Misomosi cb5e064526 Fixes #4395 by not assuming simd returns val 2024-12-01 11:54:50 +11:00
Misomosi b459cb6b2c Fix magnitude check in parse_f64_prefix 2024-12-01 11:54:50 +11:00
Lucas Perlind 28d01ce7b5 cached.cpp: Improve internal cached robustness
Do not memory map files; Windows cannot write to a file that is memory
mapped.
Write cache after llvm building. This ensures the cache won't have a
false positive if llvm fails.
2024-12-01 11:54:50 +11:00
laytan 182a916092 fix erronous updating alignment of external global 2024-12-01 11:54:50 +11:00
Colin Davidson 79975efb7e add better comment about freebsd hacks 2024-12-01 11:54:50 +11:00
Colin Davidson f7fffc4b27 Update core/time/timezone/tzdate.odin
Co-authored-by: Feoramund <161657516+Feoramund@users.noreply.github.com>
2024-12-01 11:54:50 +11:00
Colin Davidson e4983831de Update core/time/timezone/tzdate.odin
Co-authored-by: Feoramund <161657516+Feoramund@users.noreply.github.com>
2024-12-01 11:54:50 +11:00
Colin Davidson f2711dca7f add julian day rule resolvers 2024-12-01 11:54:50 +11:00
Colin Davidson 83932280f8 swap datetime_to_str to aprintf 2024-12-01 11:54:50 +11:00
Colin Davidson 0ed3d459f7 delete local_str with the appropriate allocator 2024-12-01 11:54:50 +11:00
Colin Davidson e8b6652aba sort out windows enum names too 2024-12-01 11:54:50 +11:00
Colin Davidson 8875921ec7 tweaks per laytan suggestions 2024-12-01 11:54:50 +11:00
Colin Davidson fc9983e9c8 Initial cut of timezones 2024-12-01 11:54:50 +11:00
Tom Solberg b7e61095a9 cbor: fix capacity and ptr calculation for dynarray unmarshal 2024-12-01 11:54:50 +11:00
Laytan Laats 357f463372 odin/parser: fix offsets of value declarations
Fixes #4356
2024-12-01 11:54:50 +11:00
IllusionMan1212 1f2875e939 fix(core:{odin,c}/tokenizer): Don't error on valid \uE000 codepoint 2024-12-01 11:54:50 +11:00
Laytan Laats f56ac466c3 encoding/json: fix leak when string is unmarshalled into non-string field
Fixes #4391
2024-12-01 11:54:50 +11:00
Laytan Laats cded6b8479 possibly fix not having shared dir in recent windows releases
Probably caused by https://github.com/actions/upload-artifact/issues/602
Possibly fixes #4384
2024-12-01 11:54:49 +11:00
flysand7 d41c7d52e7 Fix indentation 2024-12-01 11:50:00 +11:00
flysand7 d48c351330 Fix indentation 2024-12-01 11:48:52 +11:00
flysand7 596921fb7a First pass 2024-12-01 11:42:24 +11:00
FourteenBrush f9dc848926 Pass allocator to implicitly (de)allocating procs in core:log 2024-11-30 23:43:39 +01:00
Waqar Ahmed 8a27042d24 Use a proper Queue in thread.Pool
With lots of tasks the dynamic array takes a big performance hit as its
allocating all the time on pop_front
2024-11-30 22:29:47 +05:00
Jeroen van Rijn 314c41ef33 Merge pull request #4534 from laytan/dynlib-unload-before-load
dynlib: unload library before loading again & add LIBRARY_FILE_EXTENSION constant
2024-11-28 21:20:07 +01:00
Laytan Laats 1cece52359 dynlib: unload library before loading again & add LIBRARY_FILE_EXTENSION constant 2024-11-28 21:08:08 +01:00
Jeroen van Rijn 6d83755e92 Fix assert when return value expected. 2024-11-28 20:44:57 +01:00
Laytan Laats 8050622fe6 add map_entry procedure 2024-11-28 20:07:54 +01:00
Jeroen van Rijn 276928170c Merge pull request #4532 from Kelimion/open_fix
Make `O_RDONLY` default for `os.open` on all platforms.
2024-11-28 16:04:49 +01:00
Jeroen van Rijn 8581240ece Make O_RDONLY default for os.open on all platforms.
And also moved Windows file procs to `os_windows.odin`, in line with all the other platforms who didn't have a dedicated `file_<platform>.odin`
2024-11-28 15:57:48 +01:00
gingerBill bb96e54308 Merge pull request #4531 from Nave55/master
Fix math binomial proc giving wrong result
2024-11-28 11:27:25 +00:00
Evan Martinez 36481f6d4a Fix binomial function 2024-11-28 00:28:26 -07:00
gingerBill 44124cb639 Merge pull request #4440 from 0dminnimda/support_llvm19
Add support for llvm version 19
2024-11-27 21:15:59 +00:00
Laytan Laats fa39d87f88 properly keep track of current scope for debugging
Fixes #4519
2024-11-27 20:55:48 +01:00
gingerBill a7b02a9e08 Merge pull request #4525 from zhylmzr/master
fix `DNS_RECORD.Data` error align on windows i386
2024-11-27 18:19:57 +00:00
Jeroen van Rijn 7d17902c2a Merge pull request #4526 from Kelimion/fix-4523
Check `type_expr` in `check_procedure_param_polymorphic_type`
2024-11-27 15:35:42 +01:00
Jeroen van Rijn c7dec10100 Check type_expr in check_procedure_param_polymorphic_type
Fixes #4523 assert.
2024-11-27 15:26:33 +01:00
zhylmzr c2b6a14cd7 fix DNS_RECORD.Data error align on windows i386
fixed: https://github.com/odin-lang/Odin/issues/4520
2024-11-27 20:15:34 +08:00
gingerBill 83f67f5c70 Merge pull request #4524 from andreas-jonsson/pkgsrc-update
Updated NetBSD CI to pkgsrc Q3 release
2024-11-27 11:35:17 +00:00
Andreas T Jonsson 868e0f262c Updated NetBSD CI to pkgsrc Q3 release 2024-11-27 11:22:31 +01:00
Jeroen van Rijn 2b94886ef3 Merge pull request #4522 from laytan/rework-macos-version-retrieval
sys/info & odin report: rework macos version retrieval
2024-11-26 22:59:16 +01:00
Laytan Laats ad80aa6d28 sys/info & odin report: rework macos version retrieval 2024-11-26 22:28:21 +01:00
Laytan Laats ef3d51fad2 vendor/raylib: revert removal of arm64 raygui binaries and fix import paths 2024-11-26 18:59:51 +01:00
Laytan Laats 767daf4a9c add macos 15.1.1 to odin report and sys/info 2024-11-26 18:46:27 +01:00
gingerBill 9115c7aa13 Convert mutex guard to "try lock" 2024-11-26 16:14:13 +00:00
Jeroen van Rijn be5cdd759e Merge pull request #4517 from Kelimion/raylib5
Add aliases for Is*Ready -> Is*Valid
2024-11-25 20:26:15 +01:00
Jeroen van Rijn d315d357ca Add aliases for Is*Ready -> Is*Valid 2024-11-25 20:18:53 +01:00
Jeroen van Rijn 7c3ce334d6 Fix #4508 for abs, min, max (#4516)
* Fix #4508 for abs, min, max and the rest of the builtins.

None of these segfault now:
```odin
package bug

main :: proc() {
	p :: proc() {}

	// _ = len(p())
	// _ = cap(p())

	// _ = size_of(p())
	// _ = align_of(p())

	// T :: struct {}
	// _ = offset_of(p())
	// _ = offset_of(T, p())
	// _ = offset_of(p(), foo)
	// _ = offset_of(p(), "")

	// _ = type_of(p())
	// _ = type_info_of(p())
	// _ = typeid_of(p())

	// A: [4]int
	// _ = swizzle(p())    //  :: proc(x: [N]T, indices: ..int) -> [len(indices)]T ---
	// _ = swizzle(A, p()) //  :: proc(x: [N]T, indices: ..int) -> [len(indices)]T ---

	// _ = complex(p(), p())
	// _ = quaternion(p(), p(), p(), p())
	// _ = quaternion(w=p(), x=p(), y=p(), z=p())

	// _ = real(p())
	// _ = imag(p())
	// _ = jmag(p())
	// _ = kmag(p())
	// _ = conj(p())

	// _ = expand_values(p())

	// _ = min(p())
	// _ = max(p())
	// _ = abs(p())
	// _ = clamp(p(), p(), p())

	// _ = soa_zip(p())
	// _ = soa_unzip(p())
}
```
2024-11-25 15:27:35 +01:00
gingerBill f213b8e5cf Allow for odin help build etc 2024-11-25 14:04:17 +00:00
Jeroen van Rijn 1a0a6c485d Add comment explaining #4515 test. 2024-11-25 13:47:04 +01:00
Jeroen van Rijn 2dc0187836 Test #4515 2024-11-25 13:16:27 +01:00
o:tone c3478e0002 fix unmarshal unhandled error (#4515)
* fix unmarshal unhandled error
2024-11-25 13:15:33 +01:00
Jeroen van Rijn d3d3cbf186 Merge pull request #4512 from lxmcf/master
raylib: Update to 5.5
2024-11-25 11:16:28 +01:00
lxmcf 29839ea9e2 Resolve indentation issues 2024-11-25 21:09:10 +11:00
Alex Macafee 6ebea39b3e Add missing trailing commas 2024-11-25 19:50:34 +11:00
lxmcf b76781015b Update vendor:raylib to raylib 5.5 2024-11-25 19:37:43 +11:00
ed 1a4d6dbaf8 update script to default build compiler in release mode 2024-11-24 18:39:04 -05:00
ed 4f80bf7ebd Merge tag 'dev-2024-11' 2024-11-24 18:12:19 -05:00
gingerBill a84fcd03da Delete imports of removed packages 2024-11-24 12:35:05 +00:00
gingerBill 12e7ff1e3c Remove core:c/frontend 2024-11-24 12:32:10 +00:00
Jeroen van Rijn 73ab881eda Merge pull request #4510 from Kelimion/fix_4509
Fix #4509
2024-11-24 13:15:02 +01:00
Jeroen van Rijn 56e4da8546 Fix #4509 2024-11-24 13:08:24 +01:00
Laytan e607cbe930 Merge pull request #4506 from laytan/vet-cast-check-actually-castable
checker: only error with -vet-cast when it is actually castable
2024-11-21 19:30:14 +01:00
Laytan Laats 83bf0c6ab8 checker: only error with -vet-cast when it is actually castable 2024-11-21 19:18:17 +01:00
gingerBill a88ac1d210 Merge pull request #4505 from colrdavidson/tzone_fix
Parsing fix for timezones that have an uneven number of utc / st tags
2024-11-21 15:30:17 +00:00
Colin Davidson d60fb5a44e update to master 2024-11-20 15:51:08 -08:00
Colin Davidson f8586d0051 oops, copy-paste-bug 2024-11-20 15:33:20 -08:00
Colin Davidson da3a7a25c7 oops 2024-11-20 14:07:23 -08:00
Colin Davidson 3bb73eacfc fix parsing issue around utc/localtime split 2024-11-20 12:09:32 -08:00
gingerBill 3229f4668d Improve odin help -foo usage 2024-11-18 23:35:10 +00:00
Jeroen van Rijn 5955881d3c Merge pull request #4499 from Waqar144/patch-1
Fix typo, its supposed to be #config
2024-11-18 20:18:43 +01:00
Waqar Ahmed aafa7a04ab Fix typo, its supposed to be #config
Otherwise compile errors out when importing the file with the error:

```odin
vendor/lua/5.2/lua.odin(10:15) Error: Undeclared name: config 
        LUA_SHARED :: config(LUA_SHARED, false) 
```
2024-11-18 23:58:02 +05:00
gingerBill 8f845c7f73 Update radlink.exe 2024-11-17 21:47:46 +00:00
Jeroen van Rijn d118f88cd5 Merge pull request #4494 from jakubtomsu/min-max-one-numeric-param-error
[checker] Report error when builtin `min`/`max` has only one numeric parameter
2024-11-17 21:53:45 +01:00
jakubtomsu 86c84f2621 Fix a bug in hxa decoder found by the new check 2024-11-17 21:35:49 +01:00
jakubtomsu 71880eb1ff report error when builtin min/max has 1 (non-type) param 2024-11-17 21:02:30 +01:00
Laytan b3b276c473 Merge pull request #4493 from Dudejoe870/quaternion-dot-fix
Fix typo in the Quaternion dot product implementation
2024-11-17 18:55:15 +01:00
Dudejoe870 4d22f1f544 Fix typo in Quaternion dot product 2024-11-17 10:42:59 -06:00
Laytan Laats 20f4f378b2 sys/posix: add MAP_ANONYMOUS 2024-11-17 13:52:08 +01:00
Laytan Laats 8f2766c4dc add missing macos version 2024-11-16 15:42:13 +01:00
Jeroen van Rijn 40eeaf42b9 Merge pull request #4490 from Tetralux/fix-make-map-alloc
[runtime] `make(map[K]V)` should not allocate any capacity
2024-11-16 12:56:00 +01:00
Tetralux 2f85257bad [runtime] make(map[K]V) should not allocate any capacity
`make(map[K]V)` was resolving to `make_map_cap()` which allocates initial capacity when it wasn't intended to.
It now calls `make_map()` which doesn't allocate any capacity.

Both `make(map[K]V)` and `make(map[K]V, allocator)` will NOT allocate initial capacity now.
2024-11-16 06:13:12 +00:00
gingerBill 0781871efd Merge pull request #4489 from laytan/os2-dir-leak-and-test
os2: fix leak in dir_windows, fix netbsd, and add a test for dir reading
2024-11-15 23:22:14 +00:00
Laytan Laats 282d956aa7 os2: skip dir test when unsupported 2024-11-15 21:56:55 +01:00
Laytan Laats ce74325673 sys/posix: fix dirfd on netbsd 2024-11-15 21:22:23 +01:00
Jeroen van Rijn a3442b22da Merge pull request #4488 from NicknEma/win32-struct-fix
Fix integer type
2024-11-15 21:17:35 +01:00
NicknEma 5486327e0b Fix integer type
Change int to i32 so it is the correct size
2024-11-15 21:10:55 +01:00
Laytan Laats de9d0134e4 os2: fix file type detection in dir_windows 2024-11-15 21:08:14 +01:00
Laytan Laats 71020d7642 os2: add read dir test 2024-11-15 20:47:51 +01:00
Laytan Laats b3c2f5cb12 os2: fix leak in dir_windows 2024-11-15 20:47:34 +01:00
gingerBill 2af014b960 Make lowercase 2024-11-14 17:42:21 +00:00
gingerBill 7adb4c91d4 Fix typo 2024-11-14 17:05:34 +00:00
gingerBill b9886dfcc7 Add -linker:<string> to replace -lld and -radlink 2024-11-14 17:04:45 +00:00
gingerBill 26f6741674 Check for more errors in json.unmarshal 2024-11-14 16:45:36 +00:00
gingerBill 8de6909198 Disallow -lld and -radlink to be used together 2024-11-14 16:35:48 +00:00
gingerBill f57d531a52 Merge branch 'master' of https://github.com/odin-lang/Odin 2024-11-14 16:34:04 +00:00
gingerBill b5a9b8b6c3 Add radlink.exe 2024-11-14 16:33:54 +00:00
gingerBill 21a25bddde Add -radlink 2024-11-14 16:32:26 +00:00
gingerBill 537ff3beb3 Merge pull request #4482 from A1029384756/master
core:sys/linux - implemented inotify
2024-11-14 16:23:08 +00:00
gingerBill c440122d93 Remove relative types from json marshaller 2024-11-14 16:18:41 +00:00
gingerBill cf819f45fd Merge branch 'master' of https://github.com/odin-lang/Odin 2024-11-14 16:17:30 +00:00
gingerBill e38a08013e Remove #relative types from the compiler 2024-11-14 16:17:24 +00:00
gingerBill b3d1d7b835 Make #relative types an error in parsing 2024-11-14 16:08:53 +00:00
gingerBill d9968771d1 Merge pull request #4486 from alexover1/master
Add STICKYKEYS, TOGGLEKEYS, and FILTERKEYS to core:sys/windows
2024-11-13 21:53:53 +00:00
Alex Overstreet 5ea7fe14dd Use tabs instead of spaces 2024-11-13 15:46:56 -06:00
Alex Overstreet 0af183485b Add STICKYKEYS, TOGGLEKEYS, and FILTERKEYS 2024-11-13 15:41:16 -06:00
Laytan 7cec3044db Merge pull request #4484 from spahnke/add-bindings
Add NSApplication bindings for `mainWindow` and `keyWindow`
2024-11-13 20:18:23 +01:00
gingerBill 89a5decc33 Keep ASAN happy on type assertions 2024-11-13 18:32:50 +00:00
A1029384756 8f80e9765e core:sys/linux - prefixing + moved IN_CLOSE/IN_MOVE to constants 2024-11-13 12:45:58 -05:00
A1029384756 1b313a4db0 core:sys/linux - flags, spacing, inotify_init 2024-11-13 08:52:33 -05:00
Sebastian Pahnke 395fa7fdb8 Add NSApplication bindings for mainWindow and keyWindow 2024-11-13 14:42:31 +01:00
A1029384756 37441bd730 core:sys/linux - fixed vet errors 2024-11-13 00:09:38 -05:00
A1029384756 bb20338987 core:sys/linux - implemented inotify
core:sys/linux - added constants and spacing
2024-11-13 00:05:58 -05:00
gingerBill 91bd5d4418 Merge pull request #4479 from p2jason/master
Increased the size of Javascript keyboard event key/code buffer size
2024-11-12 15:58:58 +00:00
p2jason 2beb495140 Increase size of JS keyboard event key/code buffer size 2024-11-12 13:37:08 +13:00
gingerBill 764c32fd3e Merge pull request #4477 from laytan/enum-value-has-name
reflect: add `enum_value_has_name` proc
2024-11-11 21:30:19 +00:00
Laytan bed6828ea3 Merge pull request #4454 from amekusa/fix-build-sh
Fix: `build_odin.sh` always runs demo regardless of argument
2024-11-11 19:02:57 +01:00
Laytan Laats 9c374b4d02 reflect: add enum_value_has_name proc
Easy way to check if the current value has a defined name/member in the
enum type.
2024-11-11 18:56:59 +01:00
Jeroen van Rijn 287774ed6f Merge pull request #4476 from Bazzas-Forks/slice-size
Add core:slice.size
2024-11-11 11:14:46 +01:00
Jeroen van Rijn 74178cd741 Merge pull request #4471 from bayo-code/list-supported-targets
List the supported targets using `odin build . -targets:?`
2024-11-11 10:43:56 +01:00
bayo-code 8585fdf25f Added support for odin build -target:? 2024-11-11 04:16:01 +01:00
bayo-code d5b221f972 Revert "List the supported targets using odin targets"
This reverts commit b589e3c499.
2024-11-11 04:09:53 +01:00
Bazzagibbs cb0c1663b7 Add core:slice.size to get the byte size of a slice's backing data 2024-11-11 14:04:59 +11:00
bayo-code b589e3c499 List the supported targets using odin targets 2024-11-10 07:16:13 +01:00
Jeroen van Rijn da196a2b74 Merge pull request #4470 from clankill3r/patch-2
Update demo.odin
2024-11-09 19:55:32 +01:00
Doeke Wartena 602dab3864 Update demo.odin
type: turns -> returns
2024-11-09 19:47:00 +01:00
Jeroen van Rijn 76bf28ef2e Merge pull request #4468 from Cthuflu/patch-doc-1
Correct zlib usage in doc
2024-11-09 00:18:51 +01:00
Jacob Pfeiffer 4029ddb2b3 Correct zlib usage in doc 2024-11-08 10:32:26 -05:00
gingerBill 2b72407cf3 Merge pull request #4465 from apatterndarkly/examples-readme-relative-links
fix relative links in examples/README.md
2024-11-08 13:39:32 +00:00
gingerBill 4890c3681c Merge pull request #4467 from clankill3r/patch-1
Update scanner.odin
2024-11-08 13:38:29 +00:00
gingerBill 20a8c97d68 Remove duplicates in -defineables 2024-11-08 11:24:00 +00:00
Laytan e03f998c27 Merge pull request #4462 from A1029384756/master
Added Unlinking Section to Posix Socket Binding Documentation
2024-11-07 21:37:50 +01:00
Doeke Wartena b492b73ff2 Update scanner.odin
remove duplicated wording in comment
2024-11-07 20:15:22 +01:00
Jeroen van Rijn 1b16ddbb3e Merge pull request #4464 from Kelimion/should_use_native
Suggest `-microarch:native` if `popcnt` instruction is missing.
2024-11-07 15:09:24 +01:00
Jeroen van Rijn 3bfe675a68 && 2024-11-07 15:02:19 +01:00
AP Darkly 190ab5543d fix relative links in examples/README.md
This fix adjusts the links for 'demo', 'core', 'all', and 'vendor' so that they navigate to the intended destinations instead of yielding 404s.
2024-11-07 13:58:57 +00:00
Jeroen van Rijn deb562613f Phrasing! 2024-11-07 13:13:58 +01:00
Jeroen van Rijn 925d8749e0 Suggest -microarch:native if popcnt instruction is missing.
Fixes #4453.
2024-11-07 12:56:49 +01:00
A1029384756 5be7ac4039 added unlinking section to posix socket binding documentation 2024-11-06 20:36:29 -05:00
Laytan fd442b8678 Merge pull request #4461 from nickk-dv/master
Fix random sequence bindings in vendor raylib
2024-11-06 22:31:00 +01:00
nickk-dv c2dd15b5d3 fix LoadRandomSequence binding in vendor raylib 2024-11-06 22:39:48 +02:00
gingerBill f02d621a8e Merge pull request #4394 from seventh-chord/errormessages
Suggestion when assigning enum to bit_set
2024-11-06 13:10:17 +00:00
gingerBill e8f231ee72 Merge pull request #4437 from dpoetzschke/fix/windows-args-escaping
fix windows args parser problem from issue #4393
2024-11-06 13:08:55 +00:00
gingerBill 1419d0d295 Minor formatting change 2024-11-05 12:45:30 +00:00
Jeroen van Rijn 013c1d3128 Merge pull request #4456 from colrdavidson/timezones_fix
add new test, better fail-check, and non-transitioning tz fix
2024-11-05 12:55:16 +01:00
Colin Davidson b2d1fbba9c oops, missed a comma 2024-11-05 03:48:47 -08:00
Colin Davidson c9158b3220 add new test, better fail-check, and non-transitioning tz fix 2024-11-05 03:44:07 -08:00
Satoshi Soma 26c3c2a97d Fix: build_odin.sh always runs demo regardless of argument
Instead, it should run demo only if the argument was 'debug' or empty
2024-11-05 17:48:37 +09:00
Jeroen van Rijn e6475fec4d Merge pull request #4449 from 0dminnimda/add-pie
Link as PIE for PIC by default
2024-11-04 14:25:31 +01:00
gingerBill a0b35f67f8 Fix previous commit for arrays 2024-11-04 12:51:54 +00:00
0dminnimda 5e308cef5e Revert further simplifiction 2024-11-04 15:50:43 +03:00
gingerBill bbf76fa43e Fix bug for foo().bar where foo() is a 0-value expression 2024-11-04 12:49:43 +00:00
0dminnimda 8ad5e46ff8 Simplify further 2024-11-04 15:44:07 +03:00
0dminnimda c26e7e17a1 Simplify use of pie 2024-11-04 15:39:51 +03:00
gingerBill 31ea10490f Fix auto_cast matrix bug 2024-11-04 12:35:17 +00:00
gingerBill aa36ae01cf Fix #4406 os2 to not close the std file handles but rather just free the memory for the ^File data. 2024-11-04 11:55:29 +00:00
Jeroen van Rijn 7a98b58189 Merge pull request #4451 from NicknEma/contextless-marks
Mark procs as "contextless" in winerror.odin
2024-11-04 11:37:32 +01:00
NicknEma cc29b41ccc Mark procs as "contextless" in winerror.odin
So that they can be called from places like the windproc and stuff.
2024-11-04 10:24:27 +01:00
0dminnimda 35f1b0f11e Add support for linking as pie 2024-11-04 02:35:49 +03:00
Jeroen van Rijn 468bd3dfde Merge pull request #4447 from Kelimion/is_aligned
`mem.is_aligned` is in bytes, not log2 bytes
2024-11-03 14:16:23 +01:00
Jeroen van Rijn c33d2ff96b Missing paren. 2024-11-03 14:10:29 +01:00
Jeroen van Rijn 9199c6df34 mem.is_aligned is in bytes, not log2 bytes
Fix formula and clarify comment
2024-11-03 14:07:31 +01:00
0dminnimda d04ff6951a src/main.cpp: apply suggestion
Co-authored-by: Laytan <laytanlaats@hotmail.com>
2024-11-02 21:59:15 +03:00
0dminnimda d06fcbfdd3 Update version in more places 2024-11-02 00:53:13 +03:00
Laytan 7cfaf0b181 Merge pull request #4415 from p2jason/master
Remove the event queue from odin.js and directly invoke callbacks so they are executed in context where prevent default is possible
2024-11-01 19:48:36 +01:00
Laytan Laats 8b5492dd4d fix tabs 2024-11-01 18:10:20 +01:00
Laytan Laats 92bc3a5b4d add time/timezone to docs 2024-11-01 18:01:49 +01:00
Laytan Laats 80393cb708 add CoreFoundation and Security to docs 2024-11-01 16:47:48 +01:00
Laytan Laats 7fd32a74c5 add kqueue to docs 2024-11-01 16:42:06 +01:00
Laytan Laats f798f0b446 testing: separate the posix import into target files
This is needed for the docs generator to generate all the docs for the
posix package, if it is imported like it was on Windows it would
generate docs for the Windows version of the package which has much less
symbols exposed.
2024-11-01 16:27:45 +01:00
gingerBill c3971fe5fa Merge pull request #4441 from Barinzaya/raymath-vectortransform-translation-fix
Fix raymath not applying matrix translations
2024-11-01 13:09:31 +00:00
Jeroen van Rijn 73193e99f7 Merge pull request #4442 from peachey2k2/master
Add "-build-mode:dynamic" to the "odin help build" output
2024-11-01 14:03:55 +01:00
peachey2k2 04b000370b Add "-build-mode:dynamic" to the "odin help build" output 2024-11-01 15:51:18 +03:00
Barinzaya 30cf3ed02f Fixed raymath not applying matrix translations.
Translation matrices use the w components of the matrix to apply the
transform, and thus only work when the w component is 1. In the
original raymath implementation, the multiplication is done manually
and adds the translation components directly to the result, as if w is
1, but in the Odin binding this is done with a matrix multiplication.
However, the w component is set to 0 instead of 1, resulting in the
translation not being applied.
2024-10-31 13:37:43 -04:00
Dominik Pötzschke f1de4804a5 added braces 2024-10-31 16:18:12 +01:00
p2jason 94acfaf21e Removed event hook callback from add_*_event_listener functions 2024-10-31 13:15:39 +00:00
p2jason e825326d73 Removed event queue from add_*_event_listener JS functions and added event hook callback 2024-10-31 13:02:46 +00:00
0dminnimda d52e80502b Fix a mistake in build_odin.sh 2024-10-31 15:59:32 +03:00
0dminnimda dbed2c92b4 Add support for llvm version 19 2024-10-31 15:56:23 +03:00
Dominik Pötzschke d74f215490 adjust memory allocation 2024-10-30 22:30:56 +01:00
Laytan d4d546a63a Merge pull request #4438 from laytan/fixing-threads
fix thread_unix for Darwin after pthread corrections in posix package
2024-10-30 16:10:34 +01:00
Laytan Laats cc3c9bd871 fix thread_unix for Darwin after pthread corrections in posix package
afed3ce removed the sys/unix package and moved over to sys/posix, it has
new bindings for the pthread APIs but should have been equivalent (not).

8fb7182 used `CANCEL_ENABLE :: 0`, `CANCEL_DISABLE :: 1`, `CANCEL_DEFERRED :: 0`, `CANCEL_ASYNCHRONOUS :: 1` for Darwin, while the
correct values are `1`, `0`, `2` and `0` respectively (same mistake was made for
FreeBSD in that commit).

What this meant is that the
`pthread_setcanceltype(PTHREAD_CANCEL_ASYNCHRONOUS)` was not actually
successful, but because the error wasn't checked it was assumed it was.
It also meant `pthread_setcancelstate(PTHREAD_CANCEL_ENABLE)` would
actually be setting `PTHREAD_CANCEL_DISABLE`.

The code in this PR restores the behaviour by now actually deliberately
setting `PTHREAD_CANCEL_DISABLE` and not setting
`PTHREAD_CANCEL_ASYNCHRONOUS` which was the previous behaviour that does
actually seem to work for some reason.

(I also fixed an issue in fmt where `x` would use uppercase if it was a
pointer.)
2024-10-30 15:51:56 +01:00
gingerBill 8a00d85cea Merge branch 'master' of https://github.com/odin-lang/Odin 2024-10-30 14:12:57 +00:00
gingerBill 2392300ffb Add warning for unsigned >= 0 like conditions in a for loop 2024-10-30 14:12:49 +00:00
gingerBill f469bbb004 Merge pull request #4425 from bobsayshilol/misc-fixes
Misc fixes
2024-10-30 12:24:23 +00:00
gingerBill ee76acd665 Merge pull request #4427 from laytan/posix-additions
Finish sys/posix with Linux and partial Windows support & clean up other packages as a result
2024-10-30 11:43:47 +00:00
gingerBill 8312528a87 Merge pull request #4436 from karl-zylinski/utf8string-last-rune-bug
Fix for using `utf8string.at` with last rune index returning wrong rune
2024-10-30 11:42:47 +00:00
Dominik Pötzschke 6f966f30aa fix: fix windows params bug 2024-10-30 11:24:50 +01:00
Karl Zylinski 36b958c120 Fix for using utf8string.at with last rune index returning wrong rune. 2024-10-30 11:10:36 +01:00
Jeroen van Rijn d8187d1cf2 Merge pull request #4432 from Kelimion/fix-4431
match_exact_value: return when type is compound
2024-10-29 14:05:07 +01:00
Jeroen van Rijn b46b34228e match_exact_value: return when type is compound
fixes #4431
2024-10-29 13:59:11 +01:00
Laytan 47be77ead5 Merge pull request #4430 from Wyr0X/patch-1
fix cbor.to_json always returning array of tuples for objects
2024-10-29 11:46:51 +01:00
Jeroen van Rijn 28a3a68dc9 Fix image.which_bytes
Invert test in `which_bytes` to fix Softimage PIC detection. Fixes #4429.
2024-10-29 09:55:27 +01:00
Alexis Caraballo 31d5bc48a7 fix cbor.to_json always returning array of tuples for objects
to_json uses a small proc to check if all keys of an object are strings.
It was always returning false for any input.
2024-10-29 01:50:38 -03:00
Laytan 5f99d6b427 Merge pull request #4423 from laytan/rand-choice-bit-set
math/rand: add `choice_bit_set`
2024-10-28 20:23:45 +01:00
Laytan cb2768625a math/rand: choice_bit_set return not_empty -> ok 2024-10-28 20:07:38 +01:00
Laytan 3e024347ee Merge pull request #4426 from SrMordred/patch-1
Update process_windows.odin
2024-10-28 20:06:24 +01:00
Laytan 7e12e37df9 fix test 2024-10-28 19:58:39 +01:00
Laytan b7140875cf port pthread_mutex_t and pthread_cond_t from sys/unix cause miniaudio wants it 2024-10-28 19:42:27 +01:00
Laytan 0b4a4212bb clean up dynlib and path/filepath with sys/posix 2024-10-28 19:21:16 +01:00
Laytan afed3ce6b5 remove pthread from sys/unix and use sys/posix where used 2024-10-28 19:20:43 +01:00
Laytan e064f8c6be fix #load_directory including nested directories 2024-10-28 18:59:39 +01:00
Laytan Laats 1cebc025b0 sys/posix: impl rest of linux, impl some of Windows 2024-10-28 18:59:06 +01:00
Jeroen van Rijn d4e87f7a62 Merge pull request #4421 from IllusionMan1212/fix-escaping-rune-greater-than-U-FFFF
core/io: correctly escape runes greater than 0xFFFF
2024-10-28 14:05:43 +01:00
Patric Dexheimer b6599a52b5 Update process_windows.odin
Mistype
2024-10-27 23:27:18 -03:00
bobsayshilol b59647084b Plug a memory leak
The call to |array_make()| always allocates and since this variable was
unused it lead to a leak. Simply plug it by removing it.
2024-10-27 22:02:34 +00:00
bobsayshilol bb308b3ff4 Add missing guards around push/pop pragmas
This matches all the other places where we silence Windows warnings.
2024-10-27 22:02:34 +00:00
bobsayshilol c1496ab6c0 Fix passing nullptr to args marked as non-null
libstdc++'s |memcpy| and |memset| both state that their inputs should
never be a nullptr since this matches the C spec. Some compilers act on
these hints, so we shouldn't unconditionally call these as it would
signal to the compiler that they can't be nullptrs.

As an example, the following code will always call |do_something()|
when compiled with optimisations since GCC version 4.9:
```
    void clear(void *ptr, int size) {
        memset(ptr, 0, size);
    }
    void example(void *ptr, int size) {
        clear(ptr, size);
        if (ptr != nullptr) do_something();
    }
```
2024-10-27 22:02:34 +00:00
bobsayshilol 4f800a7fda Avoid undefined arithmetic shifting
The result of a left shift on a positive signed integer (Rune) must fit
into an unsigned integer otherwise it's undefined behaviour, as is left
shifting a negative integer by any amount. This code can only be hit if
|x >= 0xf0| and hence a left shift of 31 will always be undefined
unless the input is 0 or 1.

To avoid hitting this we can instead extend the lowest bit to be the
mask if we assume that ints are 2's complement, which we already do
elsewhere. This generates identical code in testing on Compiler
Explorer and the Odin test suite passes locally with this change.

Note that the original code would change to be defined behaviour in
C++20, however we are currently build with |-std=c++14| in the build
scripts.
2024-10-27 22:02:34 +00:00
bobsayshilol e67692b066 Avoid member access through nullptr in debug
If |result_count| is 0 then |results| will be a nullptr and hence the
access |results->Tuple| is undefined behaviour. There's already an
early return in the 0 branch so move that to be the first thing so that
we can guarantee that it's not a nullptr.

Note that technically we take the address of the result so it's not
actually dereferencing it, however UBSan doesn't care about that.
2024-10-27 22:02:34 +00:00
bobsayshilol 771d308d64 Fix invalid union access
UBSan spotted that |src->Basic.kind| had a value outside the range of
|BasicKind| due to it actually being a |Type_Pointer|. Since these are
stored in a union there could be cases where the value of |kind| just
so happens to be |Basic_string|, in which case the branch would have
been taken when it shouldn't have been.

To fix this simply check that it's a |Type_Basic| before treating it as
a |Basic|.
2024-10-27 21:24:36 +00:00
gingerBill 1f187adff4 Merge pull request #4416 from Yawning/fix/4413
src/big_int.cpp: Use square-multiply for exponentiation
2024-10-27 12:13:40 +00:00
gingerBill 35d818bb4e Fix possible leak in recursive filepath.glob 2024-10-27 12:10:10 +00:00
gingerBill f32e27d2e4 Fix bug caused due to incorrect type checking looking for context not defined in a context 2024-10-27 11:10:55 +00:00
Laytan Laats 69d375705e fix the typeid type kind of a typeid being set to Typeid_Invalid 2024-10-27 01:11:44 +02:00
Laytan Laats 44eef21997 wgpu: add missing JS impl for RenderPassEncoderSetBlendConstant 2024-10-26 22:41:52 +02:00
Laytan Laats bd38b4839c sys/wasm/js: add set_element_style 2024-10-26 22:41:14 +02:00
Laytan Laats 4608d26e6e encoding/cbor: fix skipping of ignored/missing fields in struct unmarshal 2024-10-26 22:39:46 +02:00
Laytan 1e3a924e11 Merge pull request #4420 from laytan/cbor-better-handling-of-mismatch-in-struct-and-binary-fields
encoding/cbor: handle binary having more fields than the struct by discarding
2024-10-26 17:14:44 +02:00
Laytan Laats 10c2f8dbeb math/rand: add choice_bit_set 2024-10-26 13:50:28 +02:00
IllusionMan1212 8906ffb39c core/io: correctly escape runes greater than 0xFFFF 2024-10-26 01:25:12 +02:00
Jeroen van Rijn 831558a7c2 Merge pull request #4419 from laytan/rand-choice-enum-non-contiguous
math/rand: support non-contiguous enums in choice_enum
2024-10-25 23:46:05 +02:00
Laytan Laats bb4fc9979a math/rand: support non-contiguous enums in choice_enum 2024-10-25 20:41:57 +02:00
Laytan Laats 793ef6012b encoding/cbor: handle binary having more fields than the struct by discarding 2024-10-25 20:37:55 +02:00
Laytan 3b6ed2164b Merge pull request #4399 from laytan/wgpu-improvements
wgpu: take version check out of @init, use C cc when appropriate
2024-10-25 20:15:15 +02:00
Laytan 0b8e98febe Merge pull request #4398 from laytan/image-misuse-panic
image: add panic when load is called without any registered loaders
2024-10-25 20:05:32 +02:00
gingerBill 4bde87de8f Merge pull request #4418 from laytan/check-packed-on-all-loads
check packed load and set alignment on all loads, not just lb_emit_load
2024-10-25 14:35:32 +01:00
Laytan Laats bcf2b93c6e quote the dsymutil argument
Fixes #4417
2024-10-25 15:34:59 +02:00
Laytan Laats da1e09c95d check packed load and set alignment on all loads, not just lb_emit_load 2024-10-25 15:23:15 +02:00
p2jason cf89526a9f Changed boolean parameters to bit set in the add_*_event_listener functions 2024-10-25 12:45:24 +01:00
Yawning Angel 61795232f4 src/big_int.cpp: Use square-multiply for exponentiation
For utterly unrealistic constant sizes, this still crashes on my system,
but it crashes fast due to the OOM killer, and people using rediculously
large exponents get what they deserve.
2024-10-25 11:46:47 +09:00
p2jason 8371995bfc Added parameters to the add_*_event_listener JS functions for stopping event behavior 2024-10-24 23:27:40 +01:00
gingerBill f047f804f6 Merge pull request #4402 from Lperlind/utf16_rune_count
core/unicode/utf16: add rune_count proc
2024-10-23 15:25:21 +01:00
gingerBill 33cc671302 Merge pull request #4403 from tf2spi/issue-4390-fix
Fix #4390 by assigning invalid entity type
2024-10-23 15:25:06 +01:00
gingerBill c5ae7daecd Merge pull request #4404 from tf2spi/issue-4395-fix
Fixes #4395 by not assuming simd returns val
2024-10-23 15:24:59 +01:00
gingerBill 8cba4aa1c3 Merge pull request #4410 from tf2spi/issue-4397-fix
Fix magnitude check in parse_f64_prefix
2024-10-23 15:24:48 +01:00
gingerBill 70bff68f69 Merge pull request #4408 from Lperlind/cache
cached.cpp: Improve internal cached robustness
2024-10-23 15:15:58 +01:00
Misomosi a9f2271a90 Fix magnitude check in parse_f64_prefix 2024-10-22 21:27:39 -04:00
laytan 50597e8691 fix erronous updating alignment of external global 2024-10-22 17:34:49 +02:00
Jeroen van Rijn 00ec862b63 Merge pull request #4335 from colrdavidson/datetime_tz
Add Timezone Support to Odin
2024-10-22 10:18:38 +02:00
Lucas Perlind 28b26043fb cached.cpp: Improve internal cached robustness
Do not memory map files; Windows cannot write to a file that is memory
mapped.
Write cache after llvm building. This ensures the cache won't have a
false positive if llvm fails.
2024-10-22 18:05:01 +11:00
Colin Davidson d8696badb6 add better comment about freebsd hacks 2024-10-21 21:58:32 -07:00
Colin Davidson 9e00d610c8 Update core/time/timezone/tzdate.odin
Co-authored-by: Feoramund <161657516+Feoramund@users.noreply.github.com>
2024-10-21 21:49:19 -07:00
Colin Davidson d393d3292f Update core/time/timezone/tzdate.odin
Co-authored-by: Feoramund <161657516+Feoramund@users.noreply.github.com>
2024-10-21 21:48:58 -07:00
Misomosi 6ef915c312 Fixes #4395 by not assuming simd returns val 2024-10-20 22:51:39 -04:00
Misomosi 01c7380df8 Fix #4390 by assigning invalid entity type 2024-10-20 22:45:30 -04:00
Lucas Perlind 66c53a1174 core/unicode/utf16: add rune_count proc
This returns the number of runes in a u16 slice
2024-10-21 08:29:07 +11:00
Laytan 7c1922b0a7 Merge pull request #4401 from tgolsson/ts/cbor-unmarshal-dynarray
cbor: fix capacity and ptr calculation for dynarray unmarshal
2024-10-20 21:40:05 +02:00
Tom Solberg 90a0c834bb cbor: fix capacity and ptr calculation for dynarray unmarshal 2024-10-20 21:27:16 +02:00
Laytan Laats c8ed499293 image: add panic when load is called without any registered loaders 2024-10-20 18:41:10 +02:00
Laytan Laats 62922a421c wgpu: take version check out of @init, use C cc when appropriate 2024-10-20 18:40:17 +02:00
ed 48e065ee6d update to os_windows.odin 2024-10-19 15:16:35 -04:00
ed 2a64d3f5ce update to ast_kinds and token kinds 2024-10-19 15:16:28 -04:00
ed e951b72b81 Merge remote-tracking branch 'offical/master' 2024-10-19 15:06:25 -04:00
Laytan Laats 9f609dd740 odin/parser: fix offsets of value declarations
Fixes #4356
2024-10-19 20:02:39 +02:00
gingerBill b6cbdf7c54 Merge pull request #4370 from IllusionMan1212/allow-e000-codepoint
fix(core:{odin,c}/tokenizer): Don't error on valid \uE000 codepoint
2024-10-19 18:12:08 +01:00
Laytan Laats e79f94ca5e encoding/json: fix leak when string is unmarshalled into non-string field
Fixes #4391
2024-10-19 17:08:24 +02:00
Morten Hauke Solvang 7f4ce2e179 Suggestion when assigning enum to bit_set 2024-10-19 10:25:56 +02:00
Laytan Laats b82f8df5f5 possibly fix not having shared dir in recent windows releases
Probably caused by https://github.com/actions/upload-artifact/issues/602
Possibly fixes #4384
2024-10-17 18:05:37 +02:00
Laytan 2141299d2b Merge pull request #4376 from Barinzaya/sysinfo-avx512
core:sys/info AVX-512 CPU Features
2024-10-16 19:46:01 +02:00
Laytan 1cb93efe8a Merge pull request #4382 from Barinzaya/time_32b_linux_overflow
Fixed core:time overflows on 32-bit Linux
2024-10-16 18:27:28 +02:00
Barinzaya 142e7d6b52 Fixed time overflows that occur when running in a 32-bit Linux target. 2024-10-15 13:43:28 -04:00
Barinzaya 872a29752c Renamed and trimmed AVX-512 features in sys/info.
Removed underscores from the AVX-512 names in `CPU_Feature` to make them match their equivalent LLVM target features. Removed 4FMAPs and 4VNNIW as there aren't matching LLVM target features.
2024-10-15 05:21:35 -04:00
Laytan Laats 7989d512a0 add macos 15.0.1 to odin report and core/sys/info 2024-10-14 16:19:03 +02:00
Laytan Laats 1dd9b8560d build mutex allocator code on freestanding wasm 2024-10-14 16:11:25 +02:00
Laytan Laats b746e5287e build tracking allocator code on freestanding wasm 2024-10-14 16:06:16 +02:00
Barinzaya ff35a59548 Fixed a theoretical edge case in AVX512VL support detection. 2024-10-14 09:13:27 -04:00
Barinzaya c93923c9f7 Fixed formatting. 2024-10-14 08:53:16 -04:00
Barinzaya 0e4ed515b9 Added AVX-512 feature detection to core:sys/info. 2024-10-14 08:20:23 -04:00
gingerBill 417e9bb37f Fix #4373 2024-10-13 22:26:04 +01:00
Laytan 0157ff1541 Merge pull request #4118 from andradei/posix-linux
Linux POSIX support
2024-10-13 20:05:03 +02:00
Laytan 591f827e5f Merge pull request #4371 from beaumccartney/mach-enum-member-aliases
mach darwin: enum member aliases are other enum members, not constants
2024-10-13 20:00:06 +02:00
gingerBill 55ff1769d0 Merge pull request #4368 from bersK/rlgl-binding-enablecolorblending-fix
[vendor:raylib/rlgl] Add `EnableColorBlend()` binding
2024-10-13 13:21:27 +01:00
Beau McCartney e240c034de aliases to enum members are other enum members, not constants 2024-10-12 20:11:46 -06:00
IllusionMan1212 d52e0a892c fix(core:{odin,c}/tokenizer): Don't error on valid \uE000 codepoint 2024-10-13 00:01:41 +02:00
Stefan Stefanov f112c27f7d rlgl: Add EnableColorBlend() 2024-10-12 20:01:27 +03:00
gingerBill 8006ba919e Improve formatting 2024-10-11 14:48:55 +01:00
Laytan 16eac6c844 Merge pull request #4357 from beaumccartney/mach-vm-apis
bindings, types, and constants for some mach vm apis
2024-10-10 20:04:20 +02:00
Colin Davidson 5bf8852b2e add julian day rule resolvers 2024-10-10 10:31:46 -07:00
Beau McCartney 77cf4373a8 sync policy enum 2024-10-10 11:24:55 -06:00
Colin Davidson 19c2b4d54f swap datetime_to_str to aprintf 2024-10-10 10:17:02 -07:00
Beau McCartney 4fffd1b271 kern return: doc comments above enum members 2024-10-10 11:12:42 -06:00
Beau McCartney 66c902406d align by space instead of colon 2024-10-10 11:09:06 -06:00
Beau McCartney 3aae1740c7 proc ( -> proc( 2024-10-10 11:03:55 -06:00
Colin Davidson fcaa3abe47 delete local_str with the appropriate allocator 2024-10-10 09:24:50 -07:00
Colin Davidson ba6203f8d3 sort out windows enum names too 2024-10-10 09:19:04 -07:00
Colin Davidson 4c8e355444 tweaks per laytan suggestions 2024-10-10 09:14:29 -07:00
Colin Davidson a6502c3e8c Initial cut of timezones 2024-10-09 19:26:43 -07:00
Jeroen van Rijn 4e07d3f1d3 Merge pull request #4360 from frwdrik/patch-1
Fix typo in demo.odin
2024-10-09 19:00:23 +02:00
Fredrik Vaeng Røtnes 15a8970493 Fix typo in demo.odin 2024-10-09 16:44:17 +00:00
Jeroen van Rijn 6f23b5bb60 Fix #4359
Fixes #4359
2024-10-09 14:31:01 +02:00
Beau McCartney b0ff41e673 indent with tabs not spaces 2024-10-08 19:08:13 -06:00
Beau McCartney 41c717de3f vm_flags as a bitset 2024-10-08 19:08:13 -06:00
Beau McCartney fee99c0800 move doc comment to right spot 2024-10-08 13:41:13 -06:00
Beau McCartney 58745bc7ae use b32 for boolean_t 2024-10-08 13:39:53 -06:00
Laytan Laats 5c63617191 net: fix leaking sockets in listen_tcp if an error occurs 2024-10-08 21:08:14 +02:00
Laytan Laats d8af35f01e net: fix leaking sockets in dial_tcp if connect errors 2024-10-08 21:01:57 +02:00
Beau McCartney 27753ff7a8 VM_INHERIT_* as an enum 2024-10-08 12:51:18 -06:00
Beau McCartney 9004441e43 VM_PROT_* flags as a bitset 2024-10-08 12:51:12 -06:00
Beau McCartney 2695b269a4 kern return as an enum 2024-10-08 12:44:49 -06:00
Beau McCartney 67252ff415 make some types and procs match the c apis
procs:
| type          | old  | new (matching c api)|
| ---           | ---- | ------------------- |
| kern_return_t | u64  | c.int               |
| thread_t      | u64  | mach_port_t         |
| task_t        | u64  | mach_port_t         |
| semaphore_t   | u64  | mach_port_t         |

for mach_task_self(), return mach_port_t instead of task_t

for semaphore_signal_thread(), accept a thread_t instead of a thread_act_t
2024-10-08 12:12:21 -06:00
gingerBill b839d06ac8 Merge branch 'master' of https://github.com/odin-lang/Odin 2024-10-08 11:58:28 +01:00
gingerBill 131e8d4187 Disable exe path test 2024-10-08 11:57:54 +01:00
Beau McCartney db8950922c add mach_port_deallocate - frees the port from mach_make_memory_entry() 2024-10-07 15:48:24 -06:00
Laytan Laats 6bf70b60d6 os/os2: add default permissions to write_entire_file 2024-10-07 22:31:43 +02:00
Beau McCartney 7b1086b489 make aliases of vm types not distinct
I think they're meant to be used interchangeably, just typedefed to have more
clear names for certain contexts
2024-10-07 14:24:38 -06:00
Laytan Laats 4b8462aa70 os/os2: fix mkdir_all on posix with abs path 2024-10-07 22:11:16 +02:00
Beau McCartney f858374ef2 small cleanup 2024-10-07 11:45:45 -06:00
Beau McCartney eaafe92402 remove vm_flags_t - not in the original sdk 2024-10-07 11:45:24 -06:00
Beau McCartney 15d70390e5 add missing trailing comma 2024-10-06 23:29:34 -06:00
Beau McCartney 75c5cf3e80 indent with tabs, not spaces 2024-10-06 23:02:36 -06:00
Beau McCartney 609eb00335 remove note comments 2024-10-06 22:47:46 -06:00
Beau McCartney 2fc04f29c8 make extra types distinct to fit existing types 2024-10-06 22:47:20 -06:00
Beau McCartney 5c0c1287dc put function parameters on the same line where possible to fit style 2024-10-06 22:45:10 -06:00
Beau McCartney ac4f4e883a group type definitions 2024-10-06 22:41:42 -06:00
Beau McCartney 80c390e851 add mach procedures and vm_page_size
- vm_allocate()
- vm_deallocate()
- vm_map()
- mach_make_memory_entry()
2024-10-06 22:08:23 -06:00
Jeroen van Rijn c50eaa0b77 Merge pull request #4352 from avanspector/master
build.bat: remove wmic and mandatory git requirement
2024-10-06 21:27:13 +02:00
avanspector 46ca1c8b32 Merge branch 'odin-lang:master' into master 2024-10-06 20:47:18 +02:00
avanspector bb29304029 remove wmic and mandatory git requirement 2024-10-06 20:46:41 +02:00
gingerBill ed29c881a5 Merge pull request #4351 from jakubtomsu/sys-windows-file-flags
[core:sys/windows] Add more FILE_FLAGs
2024-10-06 19:31:27 +01:00
jakubtomsu 0b74a661e3 add file flags like in WinBase.h 2024-10-06 19:53:04 +02:00
Beau McCartney a205bcd0da add VM_INHERIT constants 2024-10-05 11:19:10 -06:00
Beau McCartney 27daebf46c add vm_prot_t constants 2024-10-05 11:18:32 -06:00
Beau McCartney 04ddcc5e64 add VM_FLAGS constants 2024-10-05 11:17:37 -06:00
Beau McCartney 7eabb1d744 add KERN_RETURN constants 2024-10-05 11:15:29 -06:00
Beau McCartney 3c2efb24b7 some mach types 2024-10-05 11:11:42 -06:00
Beau McCartney 2181a42bbf rename mach import cause its not just for threads now 2024-10-05 11:09:58 -06:00
Laytan cf8f138c61 Merge pull request #4349 from MoritzHamann/master
Fix build for linux aarch64 architectures
2024-10-05 13:50:12 +02:00
Moritz 249242687c Fix build for linux aarch64 architectures
Build failed to compile on Raspberry Pi 4, with

clang: error: the clang compiler does not support '-march=native'

The build script checks $OS_ARCH for `arm64` to distinghuish between ARM
and X64 architecture. However on Raspberry Pi, the `uname -m` command
reports `aarch64` rather than `arm64`.

This change updates the EXTRAFLAGS of the `release-native` target to
check for both - `arm64` and `aarch64`.
2024-10-05 12:09:39 +01:00
Laytan 60eac68be7 Merge pull request #4346 from flysand7/os2-fix-process-exec
Don't append to buffer if nothing was read
2024-10-05 11:32:14 +02:00
Laytan Laats c21e62ddb4 reset n before stderr path too 2024-10-05 11:26:23 +02:00
flysand7 f61996fd6f Don't append to buffer if nothing was read 2024-10-05 11:06:36 +11:00
Laytan b5f7332ffb Merge pull request #4272 from flysand7/os2-noquote
[os2/process]: Don't quote arguments unless needed
2024-10-04 23:12:07 +02:00
flysand7 dad418cf91 Remove unused things 2024-10-05 07:23:15 +11:00
Laytan d0eae4a9ad Merge pull request #4342 from laytan/process-exec-improv
fix os2.process_exec on non-windows and add a smoke test
2024-10-04 19:09:13 +02:00
Laytan 54ffd6df06 better error handling 2024-10-04 15:08:21 +02:00
Laytan a3c3e5c822 reset err 2024-10-04 14:53:16 +02:00
Laytan cf705d4b29 wait instead of kill 2024-10-04 14:50:26 +02:00
Laytan 861efa4e54 Revert "add some debug logs"
This reverts commit 31ee829b44.
2024-10-04 13:58:59 +02:00
Laytan 59086a24a1 add .ENOSYS == .Unsupported for posix too 2024-10-04 13:52:54 +02:00
Laytan 424dc590a3 fix bsds process_open 2024-10-04 13:52:44 +02:00
Laytan 31ee829b44 add some debug logs 2024-10-04 13:40:25 +02:00
gingerBill abbbfd2925 Merge pull request #4340 from karl-zylinski/make-map
Add make_map that just sets the allocator without allocating anything
2024-10-04 12:26:32 +01:00
gingerBill 9fe8095a84 Merge pull request #4338 from laytan/fix-ternary-swallow-error
fix not erroring on invalid ternary
2024-10-04 12:25:54 +01:00
Laytan d9cfe692a9 make sure stdout and stderr always point to allocation 2024-10-04 13:24:40 +02:00
Laytan 64508e477b add unsupported check in process test 2024-10-04 13:24:24 +02:00
Laytan 563ed69c28 fix deadlock when in write_errno_to_parent_and_abort state 2024-10-04 13:24:14 +02:00
gingerBill c305c9dd04 [ABI FIX] Fix 128-bit ABI issues 2024-10-04 11:16:33 +01:00
gingerBill dd7c88989a Merge pull request #4341 from laytan/fix-quaternion64-arith
fix quaternion64 arith
2024-10-04 10:25:00 +01:00
Laytan Laats 386f144cca satisfy -vet 2024-10-04 10:54:27 +02:00
Laytan Laats 1d29dfd037 kill process if waiting didn't make it exit to avoid a zombie 2024-10-04 10:51:40 +02:00
Laytan Laats ae69f4b749 general cleanup 2024-10-04 10:50:14 +02:00
Laytan Laats 0b5cd3400f use dynamic array instead of string builder 2024-10-04 10:43:38 +02:00
Laytan Laats 77b033cf96 kill process if there was an error during reading to not leave a zombie 2024-10-04 10:38:47 +02:00
Laytan Laats 5d556fe277 fix idtype definition 2024-10-03 15:25:51 +02:00
Laytan Laats af8b592bf6 enable test on bsds 2024-10-03 14:45:45 +02:00
Laytan Laats 7676480526 fix temp allocator guard bug 2024-10-03 14:39:54 +02:00
Laytan Laats 77780f9ce8 fix use-after-free - closing wrong pipe 2024-10-03 14:24:00 +02:00
Laytan Laats a78cd48aa3 remove posix signal test, it isn't thread safe 2024-10-03 13:51:31 +02:00
Laytan Laats 76806080ef fix os2.process_exec on non-windows and add a smoke test 2024-10-03 13:51:27 +02:00
Laytan Laats 5d4fd09ff0 fix quaternion64 arith
Fixes #4282
2024-10-02 23:28:09 +02:00
Laytan Laats 0d834a2c2e fix paths 2024-10-02 17:52:12 +02:00
Laytan Laats 55e9a1b971 fix benchmarks not compiling and make sure it doesn't happen again by checking 2024-10-02 17:48:05 +02:00
Karl Zylinski fd05d94789 Add make_map that just takes an allocator and no capacity, similar to make_dynamic_array. This renames the old make_map to make_map_cap. 2024-10-02 17:47:04 +02:00
gingerBill 53bb6c85f7 a ordered to an ordered 2024-10-02 15:48:58 +01:00
gingerBill 21d0b073b1 Sort flags on odin build -help - #4329 2024-10-02 15:43:13 +01:00
gingerBill 3498d4341d Fix #4330 2024-10-02 15:07:22 +01:00
gingerBill aeb568f79a Ignore package runtime with using -vet-unused-packages 2024-10-02 15:04:50 +01:00
Laytan Laats 3ff887c6b6 fix not erroring on invalid ternary
For example: `a: f32 = true ? 1 : len` would get to the back-end without
errors.

Fixes #1690
2024-10-02 15:55:46 +02:00
Jeroen van Rijn 613f231fed Merge pull request #4336 from Kelimion/slice_to_type
Add `slice.to_type`
2024-10-01 23:45:59 +02:00
Jeroen van Rijn eba7be34e7 Add slice.to_type 2024-10-01 23:27:15 +02:00
gingerBill af9ae4897a Merge pull request #4290 from flysand7/pipe-has-data
[os2/process]: Implement `process_exec`, and `pipe_has_data`
2024-10-01 11:30:28 +01:00
gingerBill 9f813a6263 Merge pull request #4331 from olimpiu/patch-1
Fixed confusing (and incorrect) warning
2024-10-01 11:29:45 +01:00
olimpiu 5d57fe77be Fixed confusing (and incorrect) warning
Verbose errors *is* the new default
2024-09-30 20:46:03 -04:00
Laytan Laats ab54ad3a75 sys/posix: use '#max_field_align' 2024-09-30 16:39:14 +02:00
gingerBill 9919a0cacd Merge branch 'master' of https://github.com/odin-lang/Odin 2024-09-30 15:35:52 +01:00
gingerBill 91dece1656 Change struct alignment rules for #max_field_align 2024-09-30 15:35:47 +01:00
Laytan 5cd1784d41 review/correct/cleanup posix linux PR 2024-09-30 16:00:46 +02:00
gingerBill 1e1904e9ab Merge pull request #4323 from laytan/bit-array-init
container/bit_array: add 'init' procedure
2024-09-30 15:00:45 +01:00
gingerBill d6f6099419 Merge pull request #4324 from laytan/va-list-stb-sprintf-raylib-fixe
va_list fixes for raylib & stb sprintf
2024-09-30 15:00:14 +01:00
gingerBill d712ea43eb Merge pull request #4325 from mtarik34b/document-container-of-proc
Add documentation to `runtime.container_of`
2024-09-30 15:00:03 +01:00
gingerBill 962af780ae Merge pull request #4328 from Yawning/fix/cshake-bytepad
core/crypto/_sha3: Fix edge case in cSHAKE bytepad
2024-09-30 13:56:31 +01:00
Yawning Angel cf7d705c1f core/crypto/_sha3: Fix edge case in cSHAKE bytepad
If the domain separator happens to be exactly the rate, we would
previously incorrectly add another rate-bytes of 0s.
2024-09-30 21:50:18 +09:00
gingerBill a7d7c92a53 #min_field_align & #max_field_align; deprecate #field_align in favour of #min_field_align 2024-09-30 13:05:28 +01:00
gingerBill 4b6410e225 ABI BREAKING for SysV: Change how multiple return values are handled to be separate like all other ABIs 2024-09-30 12:32:55 +01:00
gingerBill b173fa1b9a Fix LLVM 18 ABI for 128-bit integers (because LLVM broke things) 2024-09-30 11:45:24 +01:00
gingerBill 225ffdec36 Fix union comparison bug 2024-09-30 11:10:16 +01:00
Jeroen van Rijn 7f9cfd1579 Merge pull request #4327 from beaumccartney/fix-deferred-attrib-error-report
fix #4326
2024-09-30 08:01:36 +02:00
Beau McCartney e3eea1b9fa print proc types in same order as procs 2024-09-29 23:55:55 -06:00
Beau McCartney fe8325f0ad fix deferred procedure errors 2024-09-29 23:34:09 -06:00
Laytan 38fedf2631 Merge pull request #4304 from kawaii-Code/linear_search_reverse
Add linear_search_reverse and linear_search_reverse_proc
2024-09-29 21:18:49 +02:00
Nia 253edb51f7 Fix markup in linear_search and binary_search docs 2024-09-29 17:08:54 +03:00
mtarik34b 82aefd4203 Add documentation to runtime.container_of 2024-09-29 16:04:39 +02:00
Nia 3c80f15a7a Remove pointless #no_bounds_check 2024-09-29 15:51:30 +03:00
Laytan 085b725774 Merge pull request #4302 from Pariatech/enable_static_glfw_linux
Add static GLFW bindings for Linux
2024-09-29 13:55:36 +02:00
Gabriel Pariat 3039131a5f do recommendation 2024-09-29 07:46:01 -04:00
Laytan daa3bb9a3b Merge pull request #4322 from laytan/fix-errors-not-printed-after-parse-warnings
fix errors not being printed after parse warnings
2024-09-29 12:51:21 +02:00
Laytan Laats 152479052e va_list fixes for raylib & stb sprintf 2024-09-29 11:45:57 +02:00
gingerBill 90cb62c5ac Merge branch 'master' of https://github.com/odin-lang/Odin 2024-09-29 10:15:02 +01:00
gingerBill 4a616d97df Pass delta time instead of current time to odin.js step 2024-09-29 10:14:56 +01:00
Laytan Laats 642ecc363b fix errors not being printed after parse warnings
Fixes #4299
2024-09-29 11:04:37 +02:00
Laytan Laats bd45900257 container/bit_array: add 'init' procedure 2024-09-29 10:57:42 +02:00
Laytan Laats eccb548935 fix box2d World_Draw not taking a pointer 2024-09-29 10:50:31 +02:00
Laytan a82f26f4c0 Merge pull request #4320 from laytan/fix-wgpu-examples-after-js-move
fix wgpu examples after move of files in 95721fe
2024-09-29 10:46:13 +02:00
Laytan Laats eeaa9f048b fix wgpu examples after move of files in 95721fe 2024-09-29 10:39:28 +02:00
flysand7 ca9cfc7167 remove extra binary 2024-09-29 08:01:47 +11:00
flysand7 0e446e1d68 adjust docs 2024-09-29 07:54:29 +11:00
gingerBill 90d024fb70 Merge pull request #4310 from wrapperup/fix-vulkan-wrapper
`vendor:vulkan` Update header files (to 1.3.296) and fix code generation
2024-09-28 18:22:17 +01:00
flysand7 d830069e5c [os2/process]: Implement process_exec 2024-09-28 11:25:32 +11:00
flysand7 7deb28c810 [os2/process]: Unindent doc comments 2024-09-28 10:30:54 +11:00
wrapperup 2b5c2cab1f generate new vulkan files (1.3.296) 2024-09-26 18:20:00 -04:00
wrapperup 39c8749d8f fix mismatching type generation with newer vulkan headers 2024-09-26 18:16:38 -04:00
gingerBill 4f2915a9b5 Merge pull request #4307 from flysand7/ptrace-user-regs
Fix missing registers in User_Regs on AMD64
2024-09-26 16:41:28 +01:00
gingerBill d3bff23bce Merge pull request #4308 from karl-zylinski/fix-constant-array-conversion-crash
Fix for crash when emitting a comparison between a constant array and a non-constant value.
2024-09-26 16:40:43 +01:00
Karl Zylinski 007730bfbc Fix for crash when emitting a comparison between a constant array and a non-constant value. 2024-09-25 23:42:35 +02:00
flysand7 e54b1560ee Add missing registers in User_Regs on AMD64 2024-09-26 07:27:11 +11:00
flysand7 abd52529a6 Revert "Add missing registers in User_Regs on AMD64"
This reverts commit acfac3cf2d.
2024-09-26 07:26:01 +11:00
flysand7 acfac3cf2d Add missing registers in User_Regs on AMD64 2024-09-26 07:25:40 +11:00
flysand7 842f1ae304 Fix indentation issues 2024-09-26 07:13:00 +11:00
gingerBill 8371ef6681 Merge pull request #4279 from obiwan87/master
Fix compile errors
2024-09-25 17:32:30 +01:00
gingerBill 987faa3f18 Merge pull request #4280 from Feoramund/fix-4278
Forbid parsing more fields if no separator was found
2024-09-25 16:12:33 +01:00
gingerBill e397fb6a7f Merge pull request #4297 from flysand7/ini-section
[encoding/ini]: Add missing line terminator at the end of the section
2024-09-25 16:07:03 +01:00
Nia 3337d6b264 Add linear_search_reverse and linear_search_reverse_proc 2024-09-25 16:41:55 +03:00
Gabriel Pariat fdc56c4d9a adding binding for static for linux 2024-09-24 19:44:11 -04:00
Jeroen van Rijn 791b05b14f Merge pull request #2600 from Hyrtwol/icon-for-odin-exe
Icon for odin.exe
2024-09-24 17:03:38 +02:00
Colin Davidson f3ab14b8cc Merge branch 'master' into macharena 2024-09-24 02:32:06 -07:00
Colin Davidson 99938c7d4f spawn tweaks 2024-09-24 02:31:44 -07:00
flysand7 45d26dc7f9 [encoding/ini]: Add missing line terminator at the end of the section 2024-09-24 18:57:42 +11:00
flysand7 dbad23385d [os2]: Implement pipe_has_data procedure 2024-09-24 08:12:21 +11:00
Antonino Simone Di Stefano e9e7863033 Merge branch 'odin-lang:master' into master 2024-09-22 23:32:22 +02:00
Antonino Simone Di Stefano 5bced00f5d Return Allocator_Error in map_entry_infos 2024-09-22 23:25:46 +02:00
Antonino Simone Di Stefano 357c8f6f34 Replace "." with "," in parameter list 2024-09-22 23:19:36 +02:00
Antonino Simone Di Stefano baf5a06fba Remove address operator, which lead to a type error 2024-09-22 23:16:59 +02:00
Antonino Simone Di Stefano 3d202da63f Add missing package qualifier to alloc 2024-09-22 23:15:48 +02:00
Antonino Simone Di Stefano 5a6f761535 Add missing package qualifier to Context 2024-09-22 23:15:36 +02:00
gingerBill f7d74ff3a8 Merge branch 'master' of https://github.com/odin-lang/Odin 2024-09-22 19:29:15 +01:00
gingerBill 95721fe296 Add gamepad support 2024-09-22 19:29:05 +01:00
Jeroen van Rijn ba3d545c96 Merge pull request #4281 from c-cube/add-time-to-rfc3339
add a time-to-RFC3339 conversion function
2024-09-22 17:46:26 +02:00
gingerBill 66e83ef30d Add gamepad events 2024-09-22 16:24:46 +01:00
gingerBill 94288161e9 Add new js events 2024-09-22 15:52:04 +01:00
gingerBill 130318d003 Fix assert caused by typo 2024-09-22 14:19:31 +01:00
gingerBill 1ae57d8d20 Fix more JS stuff 2024-09-22 13:32:28 +01:00
gingerBill 26d00925cc Clean-up libc usage 2024-09-22 13:20:45 +01:00
gingerBill 634fa7aa30 Move vendor:wasm/js to core:sys/wasm/js 2024-09-22 13:13:34 +01:00
gingerBill 096258b5d5 Rename runtime.js to odin.js 2024-09-22 13:08:42 +01:00
gingerBill 6bdd572a30 Merge branch 'master' of https://github.com/odin-lang/Odin 2024-09-22 13:04:29 +01:00
gingerBill c39b934e7f Remove unused imports 2024-09-22 13:04:23 +01:00
Simon Cruanes a1349d8776 fix vet warnings 2024-09-22 00:08:07 -04:00
Isaac Andrade c1a67f37e6 Fix O_Flag_Bits.EXEC for non Linux platforms on posix/fcntl. 2024-09-21 21:37:41 -06:00
Isaac Andrade cc60725eda Move bit set creation to compiler guard. Fix indentation on posix/sys_sem. 2024-09-21 21:28:18 -06:00
Isaac Andrade 04c08c2e2d Resolve bit set differences between linux and other platforms in posix/fcntl 2024-09-21 21:24:18 -06:00
Isaac Andrade c68d847fb3 Satisfy the compiler. 2024-09-21 20:59:54 -06:00
Isaac Andrade 5162c6c506 Rename sigaction duplicate type to sigaction_t on linux, following other platforms. 2024-09-21 20:56:52 -06:00
Isaac Andrade 10702f1134 Implement POSIX pthread, signal, sys/resource, unistd for Linux. 2024-09-21 20:44:33 -06:00
Simon Cruanes 32e13f17ae Apply suggestions from code review
Co-authored-by: flysand7 <yyakut.ac@gmail.com>
2024-09-21 21:08:35 -04:00
Simon Cruanes d08b3d3b82 add tests for time.time_to_rfc3339 2024-09-21 00:48:39 -04:00
Simon Cruanes a89d22b291 add time.time_to_rfc3339, a printer to RFC3339 dates
this is the counterpart to the existing parsing function
`rfc3339_to_time_utc` and others. It prints the timestamp as a string,
allocated dynamically.
2024-09-21 00:47:21 -04:00
Feoramund 84700e09c9 Forbid parsing more fields if no separator was found
Fixes #4278
2024-09-20 19:02:00 -04:00
Antonino Simone Di Stefano 355f84d0cd Use package qualifier for type_info_base and Type_Info_map 2024-09-21 00:30:50 +02:00
Antonino Simone Di Stefano b33f6ba1b0 Fix type in parameter of atomic_compare_exchange_weak_explicit
desited -> desired
2024-09-21 00:30:36 +02:00
gingerBill c1264c2a79 Merge pull request #4275 from karl-zylinski/fix-file-tags-infinite-loop
Fix for infinite loop in core:odin file tags parser when a file uses \r
2024-09-20 14:36:52 +01:00
Karl Zylinski 9a8fb2fb27 Fix for infinite loop in core:odin file tags parser when your local copy uses \r 2024-09-20 15:12:35 +02:00
gingerBill 2c5be4e054 Use .shift() instead 2024-09-20 11:18:11 +01:00
gingerBill 02884207d5 Update wasm's runtime.js 2024-09-20 11:15:47 +01:00
gingerBill b116e8ff55 Fix 128-bit integer support for wasm targets 2024-09-20 01:29:39 +01:00
gingerBill a4dd489284 Add fmt tags 2024-09-19 17:12:47 +01:00
gingerBill 290561a39b Merge pull request #4270 from flysand7/heap-alloc-resize-fix
Fix resize OOB when copying old data that's bigger than new data
2024-09-19 12:57:18 +01:00
gingerBill a7fe647c8c Merge pull request #4269 from Feoramund/fix-4256
Specify integer-like only for some `atomic_*` intrinsics
2024-09-19 12:54:11 +01:00
gingerBill 327ca2ab71 Merge pull request #4261 from laytan/net-bound-endpoint
net: add `bound_endpoint` procedure
2024-09-19 12:53:42 +01:00
gingerBill 68960e7d0a Use #+ tags 2024-09-19 12:39:56 +01:00
flysand7 ee02d04a9b [os2/process]: Don't quote arguments unless needed 2024-09-19 22:38:20 +11:00
gingerBill 6bbeb0a243 Merge pull request #4203 from karl-zylinski/file-tags-without-comments
Make tags use #+ syntax instead of //+
2024-09-19 12:36:43 +01:00
Laytan a52b1e0321 Merge pull request #4271 from Feoramund/forbid-defer-orbreak
Forbid labelled or-branch expressions within `defer`
2024-09-19 13:25:28 +02:00
gingerBill d560dad0d8 Add missing import that was accidentally deleted before commit 2024-09-19 12:09:30 +01:00
gingerBill 5441620b6c Merge branch 'master' of https://github.com/odin-lang/Odin 2024-09-19 12:06:36 +01:00
gingerBill 244907149a Move os stuff to OS specific files 2024-09-19 12:06:31 +01:00
flysand7 bec09d82df Fix vet errors 2024-09-19 21:07:08 +11:00
Feoramund acbf5c8d97 Forbid labelled or-branch expressions within defer 2024-09-19 05:59:37 -04:00
flysand7 e0bb07728d Fix resize OOB when copying old data that's bigger than new data 2024-09-19 20:55:52 +11:00
Laytan 0ca5e70c7d Merge pull request #4266 from greenya/os-get-current-directory-allocator-arg
[core/os] get_current_directory: Add allocator arg to targets where i…
2024-09-19 02:17:20 +02:00
Feoramund 9456c36684 Specify integer-like only for some atomic_* intrinsics
Fixes #4256
2024-09-18 17:18:48 -04:00
Yuriy Grynevych 80622bcb3a Merge branch 'odin-lang:master' into os-get-current-directory-allocator-arg 2024-09-19 00:13:19 +03:00
Yuriy Grynevych 18fd1fefc3 Update core/os/os_openbsd.odin
Co-authored-by: Laytan <laytanlaats@hotmail.com>
2024-09-19 00:11:17 +03:00
Yuriy Grynevych 568705069c Update core/os/os_netbsd.odin
Co-authored-by: Laytan <laytanlaats@hotmail.com>
2024-09-19 00:11:12 +03:00
Yuriy Grynevych cbf0471c72 Update core/os/os_linux.odin
Co-authored-by: Laytan <laytanlaats@hotmail.com>
2024-09-19 00:11:06 +03:00
Yuriy Grynevych 35f0dcbb92 Update core/os/os_freebsd.odin
Co-authored-by: Laytan <laytanlaats@hotmail.com>
2024-09-19 00:11:00 +03:00
Yuriy Grynevych 6e979a96a1 Update core/os/os_darwin.odin
Co-authored-by: Laytan <laytanlaats@hotmail.com>
2024-09-19 00:10:53 +03:00
Laytan Laats 7491b3c332 Fix #4265 2024-09-18 22:45:27 +02:00
Yuriy Grynevych 4ff836609c [core/os] get_current_directory: Add allocator arg to targets where its missing 2024-09-18 21:03:48 +03:00
gingerBill 8814170edf Merge branch 'master' of https://github.com/odin-lang/Odin 2024-09-18 00:13:44 +01:00
gingerBill e17dfcf7a2 Remove distinct from core:math/linalg/(glsl|hlsl) types 2024-09-18 00:13:34 +01:00
Laytan Laats 80cc2f5416 fix it more 2024-09-17 23:28:34 +02:00
Laytan Laats 9973e0255c fix error interrupt error check 2024-09-17 23:19:20 +02:00
Laytan 4dd3248507 Merge pull request #4262 from flysand7/ptrace-args
[sys/linux]: Fix the order of arguments for ptrace cont, singlestep and syscall
2024-09-17 23:15:52 +02:00
flysand7 833157ecc9 [sys/linux]: Fix the order of arguments for ptrace cont, singlestep and syscall 2024-09-18 07:52:22 +11:00
Laytan Laats 652557bfcd net: add bound_endpoint procedure 2024-09-17 22:22:19 +02:00
Karl Zylinski 29fedc1808 Changed some recently added //+ usages to #+ and also fixed some //+ usages in some code generators. 2024-09-17 19:39:48 +02:00
Karl Zylinski 093ade0504 Merge branch 'master' into file-tags-without-comments 2024-09-17 19:36:17 +02:00
Laytan Laats 6ef779cd5c add new macos releases to 'odin report' and sys/info 2024-09-17 17:47:26 +02:00
Jeroen van Rijn 9508a1f031 Merge pull request #4255 from avanspector/master
init ansi on a standalone testing exe
2024-09-17 17:15:41 +02:00
avanspector c794f853e9 init ansi on a standalone testing exe 2024-09-17 16:57:02 +02:00
Laytan Laats 0975820c48 fix wrong ulock timeout calculation, add version check for ios 2024-09-17 15:52:35 +02:00
gingerBill 0d33df15b4 Merge pull request #4208 from laytan/more-wasm-vendor-support
wasm: support more vendor libraries
2024-09-17 11:37:10 +01:00
gingerBill 4a3b4da73c Merge pull request #4253 from pkova/master
Fix core sync test deadlock on darwin
2024-09-17 11:35:18 +01:00
gingerBill 09588836e7 Add -vet-unused-procedures 2024-09-17 11:33:42 +01:00
gingerBill 19c1ed154c Add -vet-packages:<comma-separated-string-array> 2024-09-17 11:01:26 +01:00
gingerBill abf6ea7732 Fix minor bug with addressability 2024-09-17 10:24:19 +01:00
pkova 6e0f1cc866 Pass microseconds instead of nanoseconds to __ulock_wait 2024-09-17 02:35:00 +03:00
Pyry Kovanen 4d6f7dcac0 Fix code alignment in futex_darwin.odin
Co-authored-by: Feoramund <161657516+Feoramund@users.noreply.github.com>
2024-09-17 02:21:00 +03:00
pkova aa25714d43 Remove comment from core sync tests now that they're fixed 2024-09-17 02:11:41 +03:00
pkova fff99c726e Fix core sync test deadlock on darwin 2024-09-17 01:52:51 +03:00
gingerBill a16d3b6c9a Merge pull request #4242 from laytan/caller-expression
add '#caller_expression'
2024-09-16 17:36:46 +01:00
gingerBill 68619f299e Merge pull request #4209 from flysand7/core-mem
[core/mem]: Document, refactor, reformat!
2024-09-16 17:35:19 +01:00
gingerBill 017d6bdf73 Merge pull request #4232 from Feoramund/test-sync
Add test suites for `core:sync` and `core:sync/chan`
2024-09-16 17:27:20 +01: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
Isaac Andrade 97e06cb98e Fix bit flags on fcntl linux POSIX implemention. Add sys/sem linux implementation. 2024-09-15 18:43:51 -06:00
Isaac Andrade 8616842ec6 Implement Linux POSIX compliance for poll, sched, sys/select. Fix enum in fcntl. 2024-09-14 20:23:42 -06:00
Isaac Andrade aa91479870 Fix O_NOFOLLOW typo. Add Linux support for POSIX fcntl. 2024-09-14 17:01:15 -06:00
Laytan Laats d03d9e49a6 fix #4243 2024-09-15 00:03:20 +02:00
Laytan d2d2026736 Merge pull request #4241 from laytan/improve-bit-field-debug-info
improve bit field debug info
2024-09-14 22:15:47 +02:00
Laytan Laats 603efa860a add '#caller_expression' 2024-09-14 22:13:37 +02:00
Karl Zylinski 3d7b924260 Fix a few incorrectly placed build tags. 2024-09-14 18:41:05 +02:00
Karl Zylinski 19f0127e55 Moved all packages in core, base, vendor, tests and examples to use new #+ file tag syntax. 2024-09-14 18:27:49 +02:00
Isaac Andrade af94c4ab32 Add initial POSIX support for Linux for wordexp. 2024-09-14 10:06:25 -06:00
Karl Zylinski b12d312408 core/odin: Added new file tag syntax as token. parse_file stores a list of tags that the file tag parser can use later. 2024-09-14 17:59:50 +02:00
Laytan Laats 4f3f256375 improve bit field debug info 2024-09-14 15:52:37 +02:00
Karl Zylinski c24e18bf10 Fix incorrect syntax error in parse_file 2024-09-14 14:36:33 +02:00
Karl Zylinski 8b84b9a4a2 Docs are generated as expected again. 2024-09-14 14:32:46 +02:00
Karl Zylinski 86e291235d Merge remote-tracking branch 'origin/master' into file-tags-without-comments 2024-09-14 11:26:41 +02:00
flysand7 466e29bb38 [mem]: Rollback allocator API consistency 2024-09-14 13:15:02 +11:00
flysand7 016d1a84d4 [mem]: Document mutex, rollback stack and tracking allocators 2024-09-14 10:46:35 +11:00
flysand7 3ed2ab6e2c [mem]: Adjust the docs for calc_padding_with_header 2024-09-14 10:18:51 +11:00
flysand7 e90f5d2528 [mem]: Adjust the docs on the buddy allocator 2024-09-14 10:03:04 +11:00
Laytan 129d85fe7d Merge pull request #4236 from laytan/box2d-release-build
vendor/box2d: build in release mode
2024-09-13 21:09:57 +02:00
Laytan Laats 18a63037d1 vendor/box2d: build in release mode 2024-09-13 20:51:06 +02:00
gingerBill 3166c7bef9 Add Suggested Example for using an inline procedure which enables a target feature 2024-09-12 10:07:09 +01:00
Isaac Andrade 55a9ba1fc0 Finish sys/socket POSIX support for Linux. 2024-09-11 22:25:38 -06:00
Laytan 275f1cc0de Merge pull request #4233 from laytan/fix-poly-variadic-reuse-slice
fix reuse of slice for varargs with poly types
2024-09-12 02:34:01 +02:00
Laytan Laats 387f56634d fix reuse of slice for varargs with poly types 2024-09-12 02:25:44 +02:00
Jeroen van Rijn c94829f4d3 Merge pull request #4231 from InKryption/enable-doc-out-param
Enable -out:<filename> for doc subcommand
2024-09-12 01:43:22 +02:00
Laytan Laats 201a7b90bb fix EventMaskAny definition 2024-09-12 00:11:27 +02:00
gingerBill 27ed10746d Allow transmute(Bit_Set)~T(0) 2024-09-11 23:08:38 +01:00
Laytan Laats 3b22c0854c fix some LLVM assertions 2024-09-11 22:45:16 +02:00
InKryption 1025b9e6c0 Enable -out:<filename> for doc subcommand
The logic for writing the .odin-doc file to the value assigned
to out_filepath already exists, this just enables it on the CLI
frontend.
2024-09-11 21:11:32 +02:00
Laytan 244a4acfa1 Merge pull request #4230 from laytan/cbor-unmarshal-non-string-keys
core/encoding/cbor: allow unmarshalling non-string map keys
2024-09-11 16:08:53 +02:00
Laytan Laats 788e4b2b6a core/encoding/cbor: allow unmarshalling non-string map keys 2024-09-11 15:57:56 +02: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
gingerBill 9b06ea5bfd Fix #4229 for edge case os.Error/os.Errno legacy bodge 2024-09-11 12:01:01 +01:00
Laytan Laats b379d25a12 ci: try updating deprecated setup-python 2024-09-11 03:05:56 +02:00
Laytan Laats a15afccd36 ci: aware 2024-09-11 02:56:24 +02:00
Laytan Laats 83b5f82a92 ci: ohhh, I am dumb 2024-09-11 02:45:58 +02:00
Isaac Andrade 1632f19826 In-progress support for POSIX on Linux for sys/socket. 2024-09-10 18:43:09 -06:00
Laytan Laats 496d732aaf ci: does backblaze not like tar archives? 2024-09-11 02:41:28 +02:00
Laytan Laats 26db1c8860 ci: show me files 2024-09-11 02:30:43 +02:00
Laytan Laats 7ff424d148 ci: specify path 2024-09-11 02:26:39 +02:00
Laytan Laats f4322886f3 ci: really, what's in there? 2024-09-11 02:19:39 +02:00
Laytan Laats 005cadb52c ci: what's in there? 2024-09-11 02:10:55 +02:00
Laytan Laats 90ba78cdfc ci: no UTC on this python 2024-09-11 02:01:14 +02:00
Laytan Laats a66524b0b2 ci: fix run step 2024-09-11 01:55:33 +02:00
flysand7 f16ed256ea [mem]: Fix handling of default resize to check alignment 2024-09-11 08:00:27 +11:00
gingerBill b442ea8601 Merge pull request #4206 from laytan/improve-linking-shared-libraries
Improve linking shared libraries
2024-09-10 21:59:21 +01:00
Jeroen van Rijn 309ea50a7c Merge pull request #4204 from A1029384756/static_builds
Changed Linux CI builds to static linking with Musl for better compatibility
2024-09-10 22:41:25 +02:00
Jeroen van Rijn 5c4f241f22 upload v4 2024-09-10 22:21:50 +02:00
Jeroen van Rijn fce7bcec49 Merge branch 'master' into static_builds 2024-09-10 22:15:06 +02:00
Jeroen van Rijn 459de29a87 Merge pull request #4193 from odin-lang/dependabot/github_actions/dot-github/workflows/actions/download-artifact-4.1.7
Bump actions/download-artifact from 1 to 4.1.7 in /.github/workflows
2024-09-10 22:13:01 +02: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
Isaac Andrade ff82396e7c Add Linux support for POSIX sys ipc, mman, time, utsname. 2024-09-10 07:32:58 -06:00
Jeroen van Rijn beb10cce63 Fix #4227 2024-09-10 15:31:57 +02:00
Jeroen van Rijn 4df668fa22 Merge pull request #4226 from Kelimion/fix-4225
Fix #4225
2024-09-10 15:30:43 +02:00
Jeroen van Rijn 564c7821c5 Allow ExactValue_Invalid in assert.
Fixes #4225
2024-09-10 15:19:12 +02:00
flysand7 fdd4882568 [mem]: Adjust docs for alloc 2024-09-10 19:51:20 +11:00
Isaac Andrade 92ff04629e Fix some compilation errors on POSIX linux. 2024-09-09 22:17:42 -06: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
Karl Zylinski f9de8fdaba Documentation typo fix in tokenizer. 2024-09-09 21:51:34 +02:00
Karl Zylinski 580f0599cd parse_file: Removed some nesting and removed probable incorrect safety check. 2024-09-09 21:24:41 +02:00
Karl Zylinski cc724ff5d2 Made error handling code in parse_file clearer. 2024-09-09 21:13:39 +02:00
Karl Zylinski 957cd64699 Rename process_file_tag -> parse_file_tag 2024-09-09 21:06:43 +02:00
Karl Zylinski 3637dcbd04 Simplified error messages in parse_build_tag, removed the idea of making multiple notted operating systems since it was misinformed. 2024-09-09 21:03:28 +02:00
Thomas la Cour 954dd86f7a nightly define fix 2024-09-09 19:55:00 +02:00
Thomas la Cour 6298b23e07 tag nightly builds 2024-09-09 19:34:19 +02:00
Thomas la Cour 053425e8d7 trim version digits, release=YYYY.MM.0.0 else YYYY.MM.DD.0 2024-09-09 19:29:43 +02:00
ed 10861d53c0 Merge remote-tracking branch 'offical/master' 2024-09-09 13:15:00 -04:00
Laytan Laats 5ae27c6ebc wasm: support more vendor libraries
Adds support for:
- box2d
- cgltf
- stb image
- stb rect pack
2024-09-09 18:49:13 +02:00
Laytan d783bca297 Merge pull request #4218 from pkova/master
Fix os2/heap_linux.odin deadlock
2024-09-09 17:25:00 +02:00
Laytan ce3f6b60d2 Merge pull request #4223 from hstormo/bugfix
Remove stb_rect_pack implementation from stb_truetype (fix #4215)
2024-09-09 17:21:41 +02:00
gingerBill a25a9e6ebe Check for LLVM_VERSION_MAJOR >= 18 2024-09-09 14:47:44 +01:00
gingerBill 0dddd2b97e Add internal flag
`-internal-fast-isel`
2024-09-09 14:39:53 +01:00
laytan aa75909418 recompile bundled stb truetype on windows 2024-09-09 15:14:26 +02:00
Laytan Laats 0f379d7378 recompile bundled stb truetype 2024-09-09 17:09:49 +02:00
Håkon Stormo ae020ffb2e Remove stb_rect_pack implementation from stb_truetype (fix #4215) 2024-09-09 15:50:00 +02:00
A1029384756 036d7edda9 Changed Linux CI builds to static linking with Musl for better
compatibility

Changed to tarball distribution for mac and linux

Updated upload-artifact to v4
2024-09-08 18:35:16 -04:00
Laytan Laats 75dd562a0a fix #4219 - recursive mutex lock 2024-09-08 22:23:03 +02:00
pkova 0a17525791 Remove unused base:runtime from os2/heap_linux.odin 2024-09-08 17:25:30 +00:00
pkova 499a5d1f9c Fix os2/heap_linux.odin deadlock 2024-09-08 16:47:16 +00:00
gingerBill e72d0ba804 Move around mutex guard 2024-09-08 14:11:05 +01:00
Karl Zylinski f3a2b625ae Merge remote-tracking branch 'origin/master' into file-tags-without-comments 2024-09-08 11:29:21 +02:00
flysand7 167ced8ad1 [mem]: Don't use named params for dynamic pool in tests 2024-09-08 18:52:55 +11:00
flysand7 05df34f99c [mem]: Start documenting allocators.odin 2024-09-08 18:44:33 +11:00
flysand7 299accb717 [mem]: Put panic allocator after nil allocator, adjust @require_results 2024-09-08 14:17:32 +11:00
flysand7 3b30bc305c [mem]: Document raw.odin 2024-09-08 14:13:03 +11:00
Karl Zylinski 73e4954346 Better #+build tag error messages: Error when using more than one !notted operating system per build line. Error when using more than one operating system within a 'kind', such as writing #+build windows linux. 2024-09-08 03:13:21 +02:00
flysand7 f1f5dc614e [mem]: Remove old comments 2024-09-08 11:17:27 +11:00
flysand7 6eb80831b5 [mem]: Panic when allocator is not initialized 2024-09-08 11:12:28 +11:00
flysand7 b78d546010 [mem]: Add non_zeroed versions of resize 2024-09-08 11:02:17 +11:00
flysand7 c719a86312 [mem]: Document alloc.odin 2024-09-08 10:58:40 +11:00
Karl Zylinski dc767da12b Make tags use #+ syntax instead of //+ syntax so it no longer looks like a comment. Old style still works but is deprecated with a warning. Using unknown tags is now an error instead of a warning. There is a new token for #+ which consumes the whole line (or until it hits a comment). The tags are parsed like before. There are errors to tell you if you use something invalid in the pre-package-line block. 2024-09-08 01:50:56 +02:00
Jeroen van Rijn 300b01d77d Return "" for rune < 0 in strconv. 2024-09-08 00:32:46 +02:00
Laytan 1ab0745ca8 Merge pull request #4212 from karl-zylinski/fix-build-tags
Fix build tags that use ! multiple times on one line.
2024-09-07 22:18:29 +02:00
Karl Zylinski 8c636ac37b Fix build tags that use ! multiple times on one line. Those don't actually do anything since build tags use OR within the line. So something like //+build !windows, !linux would actually build on both linux and windows. What was intended in all these cases was probably AND, which you get by splitting them into separate lines. 2024-09-07 22:02:17 +02:00
Jeroen van Rijn 466a90010f Fix #4211 2024-09-07 21:07:29 +02:00
gingerBill 5a4746c3a0 Improve debug information for procedure types 2024-09-07 17:41:16 +01:00
flysand7 1842cd6297 Fix typo
Co-authored-by: FourteenBrush <74827262+FourteenBrush@users.noreply.github.com>
2024-09-08 00:09:18 +11:00
Jeroen van Rijn c4c2282595 Update 4210 test to use unaligned_load. 2024-09-07 14:05:56 +02:00
Jeroen van Rijn d2202416d2 Add test for #4210 2024-09-07 13:43:19 +02:00
gingerBill 0a08a65202 Simplify #row_major matrix and matrix_flatten behaviour 2024-09-07 12:21:29 +01:00
flysand7 f8cd13767e [mem]: Fix the issue with unbranched version of ptr align 2024-09-07 18:08:11 +11:00
flysand7 3a351ec407 [mem]: Document mem.odin 2024-09-07 18:01:41 +11:00
flysand7 7c9d2f61f5 [mem]: Update package documentation 2024-09-07 15:16:20 +11:00
flysand7 6017a20e1c [mem]: Make resize_bytes take a slice for the old memory 2024-09-07 15:11:04 +11:00
flysand7 2d988bbc5f [mem]: Rename alloc to alloc_bytes and add alloc 2024-09-07 14:45:15 +11:00
flysand7 64814f4199 [mem]: Document the package 2024-09-07 14:19:50 +11:00
flysand7 c0112d1c70 [mem]: Add free_all for buddy allocator 2024-09-07 13:27:17 +11:00
flysand7 c0e17808d4 [mem]: Split alloc and alloc_non_zeroed for buddy allocator 2024-09-07 13:26:09 +11:00
flysand7 6d3cffa13c [mem]: Add @require_results to all functions returning values 2024-09-07 13:14:58 +11:00
flysand7 b350a35b77 [mem]: Add resize_non_zeroed variant to dynamic arena, and rename pool to arena 2024-09-07 13:10:29 +11:00
flysand7 03f6b9bbf6 [mem]: Add alloc_non_zeroed variant to dynamic pool 2024-09-07 12:59:19 +11:00
flysand7 f8641ddd1b [mem]: Rename dynamic pool to dynamic arena 2024-09-07 12:33:12 +11:00
flysand7 aea3e9a585 [mem]: Fix vet errors 2024-09-07 12:26:47 +11:00
flysand7 4843db0960 [mem]: API for using small stack allocator directly 2024-09-07 12:23:55 +11:00
flysand7 de220a9aa5 [mem]: Remove the extra word 'allocator' in procedures 2024-09-07 11:07:06 +11:00
flysand7 9750b64096 [mem]: API for using stack allocator directly 2024-09-07 10:55:54 +11:00
flysand7 834f082dba [mem]: Initialize scratch allocator during calls to free and resize 2024-09-07 10:24:00 +11:00
flysand7 e5106e48a8 [mem]: API for using scratch allocator directly 2024-09-07 10:09:05 +11:00
flysand7 da6213196d [mem]: API for using arena directly 2024-09-07 09:42:04 +11:00
flysand7 2b9096517c [mem]: Code formatting 2024-09-07 09:20:56 +11:00
gingerBill 90358f97d5 Merge pull request #4205 from Valakor/wgpu
Fix wgpu on Windows - missing links to ole32.lib and oleaut32.lib
2024-09-06 14:08:07 +01:00
Matthew Pohlmann c19da21d81 Fix wgpu on Windows - missing links to ole32.lib and oleaut32.lib 2024-09-05 21:40:15 -07:00
gingerBill 78506b97a3 Merge pull request #4202 from laytan/add-fixed-point-dependency
add fixed point sign extend to 128 int deps
2024-09-05 19:08:38 +01:00
Laytan Laats 490f8c1568 add fixed point sign extend to 128 int deps 2024-09-05 15:55:55 +02:00
laytan a99e57c62c bytes: fix last_index_byte off-by-one 2024-09-05 13:30:46 +02:00
Laytan Laats ddf5ca7adf remove deprecation, technically deprecated but widely used 2024-09-05 01:08:09 +02:00
Laytan Laats 6778598bc6 support the rpath changes on macos 2024-09-05 00:12:16 +02:00
Laytan 0aa971207b add -no-rpath 2024-09-04 22:38:19 +02:00
gingerBill a4fd0c133e Merge pull request #4191 from laytan/improve-package-doc-comments
core: improve package doc comments for the documentation generator
2024-09-04 21:37:48 +01:00
Laytan ce018b4e6f Merge pull request #4197 from dekdevy/master
fix wgpu vendor lib error message
2024-09-04 22:22:25 +02:00
Laytan 1a7c1d107a set -rpath to \$ORIGIN and expect libraries next to executable just like Windows 2024-09-04 22:19:46 +02:00
dek d2d5ac33f4 fix wgpu vendor lib error message 2024-09-04 22:04:06 +02:00
Laytan 578de09775 types with explicit custom alignment are identical to types with the same natural alignment 2024-09-04 18:48:11 +02:00
Laytan dcf339517e make c vararg with any vs concrete type similar enough 2024-09-04 18:47:08 +02:00
gingerBill b2c5998e78 Merge pull request #4196 from jakubtomsu/unmarshal-json-bit-sets
Support unmarshalling bit_sets in `core:encoding/json`
2024-09-04 13:27:25 +01:00
jakubtomsu 7487d507be unmarshal bitset ints like cbor does 2024-09-04 11:08:45 +02:00
Jeroen van Rijn c6b551d2c3 Merge pull request #4194 from Feoramund/update-bit-array
Update `bit_array`
2024-09-03 23:42:27 +02:00
Feoramund 2f1228baa0 Add tests for Bit_Array 2024-09-03 17:23:42 -04:00
dependabot[bot] 73eea33b56 Bump actions/download-artifact from 1 to 4.1.7 in /.github/workflows
Bumps [actions/download-artifact](https://github.com/actions/download-artifact) from 1 to 4.1.7.
- [Release notes](https://github.com/actions/download-artifact/releases)
- [Commits](https://github.com/actions/download-artifact/compare/v1...v4.1.7)

---
updated-dependencies:
- dependency-name: actions/download-artifact
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-09-03 21:01:48 +00: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
Jeroen van Rijn 645207b8b0 Merge pull request #4192 from laytan/strings-substring-rune-wise
strings: add `substring`, `substring_to` and `substring_from`
2024-09-03 22:47:56 +02:00
Feoramund d86e56089a Fix iteration of biased Bit_Array 2024-09-03 15:34:38 -04:00
Laytan Laats 597ba796b7 strings: add substring, substring_to and substring_from 2024-09-03 21:13:35 +02:00
Laytan Laats 288312a812 core: improve package doc comments for the documentation generator 2024-09-03 19:59:04 +02:00
Laytan 6bbc165121 Merge pull request #4181 from laytan/more-riscv-sysinfo
sys/info: more CPU feature detection for RISC-V
2024-09-03 19:54:15 +02: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
Laytan 33735ba5cc Merge pull request #4180 from dvrd/alt
fix(os2): mkdir_all on path_posix
2024-09-03 19:31:04 +02:00
Jeroen van Rijn 3da77bcd67 Merge pull request #4190 from Kelimion/strings.cut
strings.cut without allocation.
2024-09-03 19:09:27 +02:00
Jeroen van Rijn 996175753c strings.cut without allocation. 2024-09-03 19:02:40 +02:00
gingerBill 0e6109e171 Merge pull request #4189 from pkova/master
Fix thread sanitizer errors surfaced by tests/core/io
2024-09-03 15:57:45 +01:00
pkova 5b9b21e756 Fix thread sanitizer errors surfaced by tests/core/io 2024-09-03 16:30:51 +03:00
gingerBill d93aca647b Merge pull request #4171 from yay/objc-runtime-bindings
More Objective-C Runtime bindings.
2024-09-03 14:28:02 +01:00
gingerBill 6ed4bfeba1 Merge pull request #4186 from Feoramund/fix-4177
Return false if `Small_Array` can't append multiple elements
2024-09-03 14:25:15 +01:00
gingerBill 99a3e9a510 Merge pull request #4187 from Feoramund/fix-slice-equal
Check for zero-length slices in `slice.equal`
2024-09-03 14:24:45 +01:00
gingerBill c0154bffad Merge pull request #4188 from FrancisTheCat/master
Added `#any_int` to some `soa` procs to mirror the behaviour of their non `soa` counterparts
2024-09-03 14:24:36 +01:00
Jeroen van Rijn 9276476760 Merge pull request #4185 from Feoramund/add-time-to-datetime
Add `time.time_to_datetime`
2024-09-03 15:05:42 +02:00
Vitalii Kravchenko c86bbc61bc More Objective-C Runtime bindings. 2024-09-03 11:41:23 +01:00
Franz Hoeltermann 02da1ac9af Added #any_int directive to some more builtin slice/dynamic array
procedures
2024-09-03 12:36:32 +02:00
Franz Hoeltermann b618b665c6 Added #any_int to some #soa procs to mirror the behaviour of their
non-soa counterparts
2024-09-03 11:46:09 +02: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
Isaac Andrade 9e4b45f0f0 Add linux to OS check. 2024-09-02 22:58:54 -06:00
Feoramund f6f2c67f37 Add time.time_to_datetime 2024-09-03 00:55:09 -04:00
Isaac Andrade d93f55c5d4 Reuse POSIX netinet_in constants for linux. 2024-09-02 22:32:52 -06:00
Isaac Andrade f072136c04 Implement POSIX linux support for poll and netinet_tcp. Incomplete support for netinet/in. 2024-09-02 21:59:03 -06:00
Jeroen van Rijn 71b2527df0 Merge pull request #4184 from Dimension4/help-text-build-mode
Add missing help text for -build-mode:test
2024-09-03 00:17:17 +02:00
Dimension4 b24157738f Add missing help text for -build-mode:test 2024-09-02 23:40:13 +02:00
Isaac Andrade 35f961d80f Add POSIX Linux support for net_if and netdb. 2024-09-02 14:25:32 -06:00
Isaac Andrade a248d49f34 Add Linux support for POSIX limits. 2024-09-02 14:04:05 -06:00
Laytan Laats 60321d98d4 also fix the doc comment in the code generator 2024-09-02 20:22:02 +02:00
Laytan Laats 195259e88b fix some doc comments 2024-09-02 20:10:11 +02:00
laytan 35731e66cf sys/info: more CPU feature detection for RISC-V 2024-09-02 14:06:19 +00:00
Dan Castrillo 54b46247bd fix(os2): mkdir_all on path_posix 2024-09-02 08:47:26 -04:00
gingerBill 16c5c69a40 Merge pull request #4175 from laytan/riscv-compiler
Support RISC-V for the compiler itself
2024-09-02 00:20:04 +01:00
gingerBill 39b49cb6fb Merge pull request #4176 from Feoramund/fix-context-error-msg
Remove extra format item at end of `context` error message
2024-09-02 00:18:15 +01:00
Feoramund 9871ad5fc8 Remove extra format item at end of context error message 2024-09-01 17:50:50 -04:00
Laytan 28c643d23f riscv compiler support 2024-09-01 21:42:47 +02:00
Jeroen van Rijn dd1f151696 Add math.remap_clamped. 2024-09-01 17:22:58 +02:00
Jeroen van Rijn c1605b5b4f Merge pull request #4173 from karl-zylinski/clamp-remap
Make math.remap clamp the result in range [new_min, new_max]
2024-09-01 16:54:17 +02:00
Karl Zylinski 6e150d1d58 Make math.remap clamp the result in range [new_min, new_max]. 2024-09-01 16:30:48 +02:00
Laytan 722b638e2c "fix" #4169, looks like llvm 14 bug 2024-08-31 19:40:05 +02:00
Jeroen van Rijn c1cb1a3d7e Simplified #assert check 2024-08-31 19:13:37 +02:00
Jeroen van Rijn a4ac50a5b4 Check for #assert condition to be a constant bool
Fixes #4170
2024-08-31 19:06:17 +02:00
gingerBill 6ba1506aa9 Fix possible leaks in os2.user_* calls 2024-08-31 15:12:47 +01:00
gingerBill b4bdb73158 Fix new(sync.Mutex) 2024-08-31 15:06:20 +01:00
gingerBill 476030dd28 Fix #4156 2024-08-31 13:51:35 +01:00
Isaac Andrade 186565b0c1 Simplify the implementation of POSIX langinfo for Linux:
No need for the enum runtime checks. Constant values were set manually
and comments were added to help locate their origin.
2024-08-30 20:34:12 -06:00
Isaac Andrade 575aedc3bf Implement POSIX support for Linux for the following facilities:
- fnmatch
- grp
- langinfo
- locale
2024-08-30 19:45:56 -06:00
Laytan Laats e0a2e52601 c/libc: fix time link name 2024-08-31 02:49:53 +02:00
Laytan Laats 7f3d8e115f remove comma 2024-08-31 02:45:17 +02:00
Laytan 584e8859bf Merge pull request #4168 from laytan/fix-bad-import-name-errors
fix some issues with the "bad import name" errors
2024-08-31 02:44:16 +02:00
Laytan Laats 8e855155fd fix bad import 2024-08-31 02:38:07 +02:00
Laytan Laats 7624ecf4ba fix some issues with the "bad import name" errors
There was so much wrong here:
- The `if` statement was never entered because even on invalid import
  names `path_to_entity_name` returns "_"
- Two errors were shown where one doesn't make sense, need to choose one
  based on context
- Structure of the messages were different from other error messages
- Suggestion was using the wrong import path
2024-08-31 02:30:32 +02:00
Laytan Laats bfedcd7035 encoding/csv: fix examples 2024-08-30 23:31:31 +02:00
Laytan Laats 6ef49d4f24 core/odin: support #type_assert and #no_type_assert 2024-08-30 23:21:35 +02:00
Jeroen van Rijn 8ad4427a25 Add a few more reflect.bit_field_* helpers. 2024-08-30 22:40:14 +02:00
Jeroen van Rijn db3bcd2cea Add reflect.bit_fields_zipped 2024-08-30 22:04:10 +02:00
Jeroen van Rijn 3072a02d5d Attempt to account for BuildTools installer's lack of \ 2024-08-30 18:54:51 +02:00
gingerBill 773703bc83 Merge pull request #4009 from thetarnav/file-tag-parser
Add a file tag parser to core:odin/parser
2024-08-30 11:58:18 +01:00
gingerBill a4e865f90b Fix #4166 2024-08-30 11:01:06 +01:00
gingerBill 9197a126fc Use XOR directly rather than (~x) & mask 2024-08-30 10:52:11 +01:00
gingerBill 38ea276231 Make ~some_bit_set work on only the possible bits by doing a mask with the full set 2024-08-30 10:48:21 +01:00
gingerBill b020b91df2 Merge pull request #4112 from Feoramund/fix-test-io-issues
Add `core:io` test suite
2024-08-30 09:57:02 +01:00
gingerBill 291048cb3b Merge pull request #4165 from avanspector/master
Add missing lexer checking delay for foreign blocks
2024-08-30 09:56:36 +01:00
Isaac Andrade 3557955f53 Align the dirent struct for linux 2024-08-29 20:17:39 -06:00
Colin Davidson 2119062a5a add more dyld support 2024-08-29 17:00:02 -07:00
avanspector 3135c89a0a Merge branch 'master' of https://github.com/avanspector/Odin 2024-08-30 01:32:21 +02:00
avanspector 47f423c123 Set a flag for delayed checking 2024-08-30 01:32:06 +02:00
avanspector a7a2611efc Merge branch 'odin-lang:master' into master 2024-08-29 23:44:14 +02:00
avanspector 9866c83d61 Add missing checker delaying 2024-08-29 23:43:01 +02:00
Damian Tarnawski 655610ec87 Satisfy vet 2024-08-29 23:06:50 +02:00
Damian Tarnawski a28d574272 Add and test match_build_tags 2024-08-29 23:02:49 +02:00
Colin Davidson 06bc3b2a36 oops, duplicate const 2024-08-29 13:41:53 -07:00
Damian Tarnawski f93779d425 Parse build_project_name as [][]string 2024-08-29 22:08:01 +02:00
Damian Tarnawski a10f988020 Move some types to runtime, use reflection instead of lut 2024-08-29 21:12:33 +02:00
Colin Davidson cc6e1bdcd6 add more dyld info collect 2024-08-29 12:02:54 -07:00
Damian Tarnawski 39bdf4d710 Add missing require_results attr 2024-08-29 20:52:27 +02:00
Damian Tarnawski 7862460374 Remove useless code 2024-08-29 20:52:27 +02:00
Damian Tarnawski 92821300e4 Add a file tag parser to core:odin/parser 2024-08-29 20:52:27 +02:00
Colin Davidson d026ac2df2 add thread-info and memmap-info 2024-08-29 11:41:36 -07:00
Laytan 94a1a7aed5 Merge pull request #4164 from laytan/virtual-growing-min-block-size-fix
mem/virtual: make sure the given size is used for subsequent blocks
2024-08-29 18:27:54 +02:00
Laytan Laats 5a22d49b72 mem/virtual: make sure the given size is used for subsequent blocks 2024-08-29 14:48:36 +02:00
Laytan 942017b958 Merge pull request #4163 from laytan/sysconf-pagesize
mem/virtual: use `sysconf` for retrieving page size and actually use these init procs
2024-08-29 14:44:54 +02:00
Laytan Laats fd2ad20cd4 mem/virtual: use sysconf for retrieving page size and actually use these init procs 2024-08-29 14:36:32 +02:00
Colin Davidson 0e344ae2d6 add ARM thread state 2024-08-29 01:54:09 -07:00
Colin Davidson c520f029bb initial posix/spawn 2024-08-29 00:54:45 -07:00
Colin Davidson 3209b319e8 more useful pieces 2024-08-28 23:50:17 -07:00
Isaac Andrade 4577d541ec Add contants RTLD contants on os_linux and posix (dlfcn). 2024-08-28 22:15:11 -06:00
Isaac Andrade f0e631cfa3 Use native types on linux POSIX structs. 2024-08-28 19:08:48 -06:00
Laytan Laats cca385209b Remove double close 2024-08-28 19:53:20 +02:00
Laytan Laats fe2d256468 Properly close the temporary files in io tests 2024-08-28 19:53:20 +02:00
Laytan Laats 0f2ad95014 Fix EOF detection is os2 window read 2024-08-28 19:53:20 +02:00
Feoramund 7fa2e56cd9 Add io tests for bufio streams 2024-08-28 19:53:20 +02:00
Feoramund 24a53c246f Make sure seek succeeds in io.Limited_Reader test setup 2024-08-28 19:53:20 +02:00
Feoramund b11fa90ed2 Test empty slice usage in io procs 2024-08-28 19:53:20 +02:00
Feoramund f453054aff Return 0, nil in all io cases where an empty slice is provided 2024-08-28 19:53:20 +02:00
Feoramund ef99373c31 Fix pread and pwrite on os2 Windows
The previous code was jumping ahead by the specified offset, instead of
getting the current offset.
2024-08-28 19:53:20 +02:00
Feoramund 1cd5cbb0e4 Test io unexpected pointer movement 2024-08-28 19:53:20 +02:00
Feoramund 56f232e5fc Report invalid whence & offset on os2 Windows 2024-08-28 19:53:20 +02:00
Feoramund de1432b315 Fix Windows infinite recursion with os2._flush 2024-08-28 19:53:20 +02:00
Feoramund e7d6e2d163 Add documentation to os2.close
Make it explicit that using a stream after closing is like a
use-after-free bug.
2024-08-28 19:53:20 +02:00
Feoramund 8b40be50b9 Update core:io tests
- Relax return value requirements on errors. Only the error is checked,
  as there are multiple conflicting return styles throughout the `os`
  API.

  Some return the error along with `0`, `-1`, or another value. This can
  be smoothed out later.

- Test `os2` files now.
- No longer test streams after closing; this is considered similar to a
  use-after-free in `os2`.
2024-08-28 19:53:20 +02:00
Feoramund 6798d15ecb Check int(abs) instead to avoid overflows 2024-08-28 19:53:20 +02:00
Feoramund 6aedb2695a Report Invalid_Whence on some os platforms
- Move `Seek`-related checks into OS-specific files for granularity.

Platforms:
- Darwin
- FreeBSD
- Haiku
- Linux
- NetBSD
- OpenBSD
2024-08-28 19:53:20 +02:00
Feoramund 0243647e15 Add missing flush functionality to os platforms
Platforms:
- FreeBSD
- Haiku
- Linux
- NetBSD
- OpenBSD
2024-08-28 19:53:20 +02:00
Feoramund 3ec4db212b Report Invalid_Whence in os2 Linux seek 2024-08-28 19:53:20 +02:00
Feoramund 7683c1f4bb Report Invalid_Whence in os2 POSIX seek 2024-08-28 19:53:20 +02:00
Feoramund ef2cd9d97f Copy missing errors in os2._get_platform_error from posix to linux 2024-08-28 19:53:20 +02:00
Feoramund 5b9e9fb822 Add test suite for core:io 2024-08-28 19:53:20 +02:00
Feoramund 741ccd7ff5 Zero n on error in _file_stream_proc 2024-08-28 19:53:20 +02:00
Feoramund eb92a2df71 Fix indentation 2024-08-28 19:53:20 +02:00
Feoramund d60f404bb4 Fix OpenBSD implementations of read_at and write_at 2024-08-28 19:53:20 +02:00
Feoramund 6c4806835c Fix indentation 2024-08-28 19:53:20 +02:00
Feoramund e1555e04ad Fix Haiku implementations of read_at and write_at 2024-08-28 19:53:20 +02:00
Feoramund 7061032db6 Fix NetBSD implementations of read_at and write_at
These procedures must not modify the underlying file pointer.
2024-08-28 19:53:20 +02:00
Feoramund 861d892ffe Make Windows pread and pwrite conform to POSIX 2024-08-28 19:53:20 +02:00
Feoramund 5c8c63ae04 Fix FreeBSD implementations of read_at and write_at
These procedures must not modify the underlying file pointer.
2024-08-28 19:53:20 +02:00
Feoramund 1ced76cdd1 Fix broken cases of Seek usage in _file_stream_proc
Handles `EINVAL`, among other fixes.
2024-08-28 19:53:20 +02:00
Feoramund e83b982afe Measure bytes.Buffer size by length instead of capacity 2024-08-28 19:53:20 +02:00
Feoramund 7c6cc81041 Add Seek behavior to bytes.Buffer 2024-08-28 19:53:20 +02:00
Feoramund 521e47ffee Don't invalidate prev_rune if Reader seek failed 2024-08-28 19:53:20 +02:00
Feoramund 8251f4d7d0 Return .EOF in bytes.buffer_read_at instead
This is consistent with the other stream `read` procs
2024-08-28 19:53:20 +02:00
Feoramund da49f7eb4e Make bytes.reader_init return an io.Stream
Makes the API like the other stream `init` procs.
2024-08-28 19:53:20 +02:00
Feoramund d66486c17e Make io.Section_Reader set base too
This should fix seeking from `.Start`, getting the `size`, and
`read_at`.

Also make the API consistent with the other `*_init` procs in
`util.odin` by returning the `io.Reader`.
2024-08-28 19:53:20 +02:00
Feoramund 981a2e1a00 Add missing io.Stream_Mode responses 2024-08-28 19:53:19 +02:00
Laytan eb6e5ee3a1 Merge pull request #4162 from laytan/os2-disable-custom-heap-allocator
os2: disable custom heap allocator
2024-08-28 19:51:22 +02:00
Laytan 5e850e24d6 os2: disable custom heap allocator
See #4161
2024-08-28 19:45:34 +02:00
Jeroen van Rijn 17d10b72d5 Merge pull request #4158 from sqrt-negativeone/master
Win32 clipboard procedures
2024-08-28 19:02:18 +02:00
Fakhri Mouad b08c14b710 fix style, ensure we compile with flags -vet -strict-style -disallow-do 2024-08-28 17:52:58 +01:00
Jeroen van Rijn d3fca60e4d Merge pull request #4160 from Kelimion/vsdd
-vet -strict-style -disallow-do
2024-08-28 18:49:44 +02:00
Jeroen van Rijn d602e2cc74 Remove duplicate vet flag. 2024-08-28 18:43:54 +02:00
Jeroen van Rijn 831e26cb6f Remove unused import. 2024-08-28 18:42:54 +02:00
Jeroen van Rijn 7b276cbc7e -vet -strict-style -disallow-do 2024-08-28 18:36:49 +02:00
Fakhri Mouad 7e4750c303 fix indentation in test file 2024-08-28 17:30:30 +01:00
Fakhri Mouad 967b6d46b2 avoid using do statement in odin codebase 2024-08-28 17:27:27 +01:00
Jeroen van Rijn fcafd83506 Merge pull request #4159 from Kelimion/disallow-do
More -disallow-do in CI.
2024-08-28 18:20:39 +02:00
Jeroen van Rijn 21dab9673d More -disallow-do in CI. 2024-08-28 18:13:53 +02:00
Fakhri Mouad 16503c3b91 Add Win32 procs needed to handle clipboard 2024-08-28 16:36:06 +01:00
Laytan Laats 1e6419b5b7 fix zombie thread leak in thread self cleanup 2024-08-28 16:22:38 +02:00
Laytan Laats ef66f96cf2 fix windows bindings where BOOL is not actually a boolean
Fixes #4157
2024-08-28 15:45:41 +02:00
Isaac Andrade 45322023e3 Merge branch 'master' of github.com:odin-lang/Odin into posix-linux 2024-08-27 18:51:58 -06:00
Laytan Laats 9684ade23e fix -vet-tabs 2024-08-27 19:13:46 +02:00
gingerBill 8694fa5f78 Minor cleanup of CFString.odin 2024-08-27 11:22:28 +01:00
Isaac Andrade 7d94810d01 Fix ino_t and ino_t32 types for POSIX linux. 2024-08-26 22:12:05 -06:00
gingerBill fb248056c9 Merge pull request #4146 from Feoramund/fix-i128-transmute-align
Fix inline transmutation of `[16]i8` to `i128`
2024-08-26 22:38:24 +01:00
gingerBill ade4e312fe Merge pull request #4154 from avanspector/master
Delay lexical checking for foreign blocks that are in file scope
2024-08-26 22:38:13 +01:00
gingerBill 12bd07d2df Merge pull request #4150 from laytan/update-wgpu-to-22-1-0
wgpu: update to v22.1.0.1
2024-08-26 22:37:31 +01:00
gingerBill 91f8c626bb Merge pull request #4148 from Feoramund/tls-cleaner
Add API for freeing `thread_local` state
2024-08-26 22:37:08 +01:00
Laytan c1684d6335 Merge pull request #4136 from flysand7/process-info-fix
[os2/process]: Don't free process info fields in partial success scenarios
2024-08-26 23:25:21 +02:00
flysand7 1a4faff9c9 [os2/process]: Fix typo on doc comments 2024-08-27 08:06:11 +11:00
Laytan 6c17642b91 Merge pull request #4155 from Feoramund/fix-test-vet-style
Fix `-vet` and `-strict-style` failures in tests
2024-08-26 23:01:21 +02:00
Laytan ef254ec055 Merge pull request #4153 from Feoramund/fix-4151
Fix #4151
2024-08-26 22:59:48 +02:00
Feoramund 1f04f541cf Fix -vet and -strict-style failures in tests 2024-08-26 16:20:08 -04:00
avanspector dd86a8f013 Merge branch 'odin-lang:master' into master 2024-08-26 21:00:25 +02:00
avanspector 43ec2b9253 checker: delay foreign block checking
if file scope, otherwise as before
2024-08-26 20:59:16 +02:00
Laytan Laats 60cd0da2ed wgpu: cont. fix sdl2glue on Linux 2024-08-26 20:24:26 +02:00
avanspector c21bbae427 Merge branch 'master' of https://github.com/avanspector/Odin 2024-08-26 19:59:20 +02:00
avanspector d7e977069a Update checker.cpp 2024-08-26 19:59:15 +02:00
Jeroen van Rijn ef98aa1fe1 Merge pull request #4152 from edyu/master
Fix error for uuid to require 36 bytes instead 32 (4 bytes for dashes)
2024-08-26 19:35:04 +02:00
Ed Yu 4e2bce0c83 Fix error for uuid to require 36 bytes instead 32 (4 bytes for dashes) 2024-08-26 10:25:10 -07:00
Feoramund d43c6e39f6 Fix #4151
The `core:mem` procs were calling the wrong `runtime` procs for their
number of arguments.
2024-08-26 13:23:04 -04:00
Laytan f56b895c05 wgpu: fix sdl2glue not using GetWindowWMInfo properly
Fixes #4127
2024-08-26 16:08:14 +02:00
Laytan Laats 54a420f3eb wgpu: update to v22.1.0.1 2024-08-26 15:49:12 +02:00
Jeroen van Rijn 3e0f6bda91 Merge pull request #4149 from Feoramund/fix-thread-pool-use-after-free
Fix use-after-free in `thread.Pool`
2024-08-26 13:05:23 +02:00
Feoramund 9fac03b84c Fix use-after-free in thread.Pool 2024-08-26 06:39:05 -04:00
Laytan 0a8f85e879 Merge pull request #4147 from Feoramund/cleanup-test-runtime-arenas
Free the arenas allocated in `test_core_runtime`
2024-08-26 12:09:34 +02:00
Feoramund 49606ec3ea Use thread_local_cleaner API in os2 2024-08-26 06:01:59 -04:00
Feoramund d338642dc4 Add API for freeing thread_local state 2024-08-26 06:01:59 -04:00
Feoramund 95d1c29c2a Free the arenas allocated in test_core_runtime
Found by using `-sanitize:address`.
2024-08-26 05:45:24 -04:00
Feoramund c424c94030 Fix inline transmutation of [16]i8 to i128
Forbids LLVM from generating SSE aligned loads on unaligned data.
2024-08-26 04:48:31 -04:00
gingerBill 8de1e88c4f Merge pull request #4144 from laytan/riscv-error-on-atomics-without-extension
riscv: add an error when atomics are used without the atomics extension
2024-08-25 22:49:42 +01:00
flysand7 3119e0489f [os2/process]: Fix vet errors 2024-08-26 07:23:59 +11:00
flysand7 db94e646e0 [os2/process]: Adjust documentation for process info 2024-08-26 07:21:54 +11:00
flysand7 4737485f09 [os2/process]: Force return on allocation errors and process not existing 2024-08-26 07:19:39 +11:00
Laytan d299d4e1cd riscv: add an error when atomics are used without the atomics extension 2024-08-25 21:17:00 +02:00
Laytan 9aeb0d0fb6 Merge pull request #4142 from laytan/os2-propogate-errors-from-execv
os2: propagate errors from execv
2024-08-25 21:09:54 +02:00
Laytan 0ea6809b49 os2: remove return on file_size error from read_entire_file
file_size can't return .No_Size because it uses io.size and only returns
an io.Error, removing this so it works when file_size fails (linux pipes
for instance)
2024-08-25 18:43:23 +02:00
Laytan Laats a0fe6da10b os2: propogate errors from execv functions to parent 2024-08-25 18:01:33 +02:00
gingerBill 8c952878fb Allow empty strings in link_prefix and link_suffix 2024-08-25 14:03:14 +01:00
gingerBill eda58357b6 Merge pull request #4141 from VladPavliuk/fix-dwmapi-enum
Fix win32 dwmapi DWMWINDOWATTRIBUTE enum.
2024-08-25 12:46:51 +01:00
gingerBill 7b14c267fb Merge pull request #4138 from z64/z64/fix-cmark
Fix binding to cmark_node_get_fence_info
2024-08-25 12:43:07 +01:00
VladPavliuk cc2ed2b302 Fix win32 dwmapi enum. 2024-08-25 14:34:24 +03:00
Colin Davidson b396280df7 add stuff needed for process control 2024-08-25 03:57:59 -07:00
Zac Nowicki 17cc423a17 Fix binding to cmark_node_get_fence_info
https://github.com/commonmark/cmark/blob/master/src/cmark.h#L334
2024-08-25 01:42:12 -04:00
flysand7 fa84e86766 [os2/process]: Allow for partial success scenarios 2024-08-25 14:22:27 +11:00
flysand7 0d7e6430eb [os2/process]: Don't free process info fields in partial success scenarios 2024-08-25 13:08:24 +11:00
Jeroen van Rijn 4cf1af3f7d Merge pull request #4135 from gelatinstudios/master
fix core:reflect/iterator.odin
2024-08-24 23:23:33 +02:00
Laytan eef4dffa12 Merge pull request #4134 from karl-zylinski/fix-raylib-LoadImageAnim-binding
Fix binding: Make rl.LoadImageAnim take a pointer instead of a multi-pointer.
2024-08-24 22:56:49 +02:00
Karl Zylinski 25e8a6353d Fix comment indentation. 2024-08-24 22:02:17 +02:00
unknown ae5ef0ce9c fix core:reflect/iterator.odin 2024-08-24 16:01:49 -04:00
Karl Zylinski 574a5015d6 Make rl.LoadImageAnim take a pointer instead of a multipointer. The param frames is just for returning an int, it's not for passing a multipointer into the proc. 2024-08-24 22:00:29 +02:00
Jeroen van Rijn 0a825fc44d Improve SRV handling in dns_windows.odin 2024-08-24 18:43:25 +02:00
gingerBill aa659a637a Fix #4132 2024-08-24 15:46:54 +01:00
gingerBill 0e71e93b22 Remove unused import 2024-08-24 14:51:28 +01:00
gingerBill 61b3af5b08 MemFree as a procedure group for both rawptr and cstring 2024-08-24 14:51:05 +01:00
gingerBill 19b95349a6 Use fmt.caprintf directly 2024-08-24 14:47:33 +01:00
gingerBill d0eaf7642d Add intrinsics.type_has_shared_fields 2024-08-24 14:36:18 +01:00
gingerBill eb799393d5 Fix -vet-tabs issues 2024-08-24 13:56:41 +01:00
gingerBill 8ba87e01bd Improve parse_enforce_tabs usage 2024-08-24 13:56:30 +01:00
gingerBill daccd72162 Merge branch 'master' of https://github.com/odin-lang/Odin 2024-08-24 13:36:51 +01:00
gingerBill 8b248673c1 Fix #4105 2024-08-24 13:36:43 +01:00
Jeroen van Rijn faec52623d Merge pull request #4128 from gordonshamway23/mini_fix_in_image
Added missing slice advancing.
2024-08-24 14:23:42 +02:00
gingerBill b6d9a0c32e Manually implement tail-recursion for parse_if_stmt 2024-08-24 13:16:55 +01:00
gingerBill a4cc207022 Add a recursion depth limit for #3987 with a consideration to use a switch statement or refactor the code to not use a large if-else chain 2024-08-24 12:59:17 +01:00
gingerBill 683dde1fa0 Disallow labelled branches in defer - fix #3960 2024-08-24 12:47:29 +01:00
gingerBill ca4d91a8a3 Fix #4079 2024-08-24 12:26:41 +01:00
gingerBill 65543b993f Merge pull request #4130 from fusion32/fix-ambiguous-generic-type-names
fix ambiguous generic type names
2024-08-24 11:50:02 +01:00
gingerBill 00fb60d3d9 #4115 Add Suggestion: 'typeid_of(T)' 2024-08-24 11:48:32 +01:00
gingerBill 68a83abcd6 #4119 Add error when doing {.A | .B} instead of {.A, .B} with a suggestion to do surround it in parentheses to make it clear it is intended 2024-08-24 11:44:59 +01:00
gingerBill 4458ca4585 Fix #4126 2024-08-24 11:40:02 +01:00
Isaac Andrade e0b78476c5 Fix else when clause. 2024-08-23 20:18:26 -06:00
Isaac Andrade 2794eb31d9 On Linux POSIX, ENOTSUP and EOPNOTSUPP have the same value. 2024-08-23 20:08:59 -06:00
Isaac Andrade d8e4a1b93f Fix comment typo on POSIX ENOTSUP constant.
Co-authored-by: Feoramund <161657516+Feoramund@users.noreply.github.com>
2024-08-23 20:02:44 -06:00
Isaac Andrade 9c06898303 Add comma to last dirent struct member. 2024-08-23 20:01:15 -06:00
Isaac Andrade 90aa7dff04 Add POSIX dirent struct for Linux. 2024-08-23 19:56:45 -06:00
Isaac Andrade 1adea2f4d6 Merge branch 'master' of github.com:odin-lang/Odin into posix-linux 2024-08-23 18:40:35 -06:00
fusion32 5ef8a092f6 fix wrong exact value kind comparison 2024-08-23 17:50:27 -03:00
fusion32 c969bee86d fix ambiguous generic type names 2024-08-23 17:18:10 -03:00
gordonshamway23 426367c522 Added missing slice advancing. 2024-08-23 21:28:59 +02:00
Laytan Laats d410281766 os2: do read_entire_file in parts if the file size is 0 2024-08-23 20:25:47 +02:00
Laytan Laats ce53805d94 os2: fix read_entire_file wrong slice end variable 2024-08-23 20:25:19 +02:00
Laytan Laats 963e8544f4 os2: CLOEXEC the fds from pipe for posix implementation 2024-08-23 20:25:05 +02:00
Laytan Laats c2a7c29ce8 os2: fix using uuid as process handle for darwin, once it goes zombie it changes 2024-08-23 20:24:06 +02:00
Laytan b3f22133f3 Merge pull request #4123 from laytan/more-core-orca-support
orca: implement core:time and core:log
2024-08-23 18:47:00 +02:00
Laytan Laats caef37bc18 orca: implement core:time and core:log 2024-08-23 18:25:10 +02:00
gingerBill 574dc5efe6 Merge pull request #4120 from laytan/posix-process
os2: process API for Darwin and most of it for BSDs
2024-08-22 22:51:48 +01:00
Laytan Laats a66520ba57 os2: process API for Darwin and most of it for BSDs 2024-08-22 23:07:24 +02:00
Laytan Laats b9043db434 os2: make platform error more ergonomic by making it an alias 2024-08-22 22:59:13 +02:00
Laytan Laats 58e5078b66 add riscv to simd.IS_EMULATED 2024-08-22 14:17:45 +02:00
gingerBill 70932dc478 Merge pull request #4089 from laytan/riscv64
add support for linux_riscv64 and freestanding_riscv64
2024-08-22 11:20:03 +01:00
Jeroen van Rijn a8bc6f08a9 Merge pull request #4116 from Kelimion/article
Add table-driven (in)definite article to some errors.
2024-08-21 18:51:43 +02:00
Jeroen van Rijn 07aedb0b89 , 2024-08-21 18:42:11 +02:00
Thomas la Cour 171d917b7e odin manifest file 2024-08-21 16:26:10 +02:00
Laytan 63cd9a031a fix variadic parameter with default value error check 2024-08-21 15:11:16 +02:00
gingerBill c77e8ca401 Fix tests 2024-08-21 14:06:04 +01:00
gingerBill 58e811eea5 Merge pull request #3962 from Feoramund/regex
Add `core:text/regex`
2024-08-21 13:55:11 +01:00
Laytan c0125f3192 correct the riscv64 stat structs 2024-08-21 14:41:23 +02:00
Jeroen van Rijn 1bcc074223 dash 2024-08-21 14:18:12 +02:00
gingerBill e7b8e61c68 Merge pull request #4106 from yeongjukang/master
core:sys/linux - implement clock_settime, clock_getres and clock_nanosleep
2024-08-21 09:41:14 +01:00
Isaac Andrade ef06cd93cc Initial implementation of linux-specifig dirent struct. 2024-08-20 20:35:56 -06:00
Isaac Andrade c0521c6d99 Add linux support for errno. 2024-08-20 20:35:28 -06:00
Yeongju Kang bbe4c32e32 changed signature of clock_getres 2024-08-21 08:25:14 +09:00
Laytan 0d39f52b4d Merge pull request #4117 from yay/vet-tabs
A couple of foundation binding. Vet tabs.
2024-08-21 01:16:30 +02:00
Vitalii Kravchenko 14169ae5b4 A couple of foundation binding. Vet tabs. 2024-08-21 00:09:09 +01:00
Jeroen van Rijn 6b4b0cea5d Add table-driven (in)definite article to some errors. 2024-08-20 22:13:31 +02:00
Laytan 85a33a1c9b add constant_log2 to intrinsics file 2024-08-20 19:14:50 +02:00
Laytan 8f2d3dc955 fix i128 division? 2024-08-20 19:01:09 +02:00
Jeroen van Rijn daa0779c01 Rewrite compound_to_time without using i128. 2024-08-20 18:50:05 +02:00
Laytan d7e81e86f5 Merge pull request #4110 from andradei/termios-linux
Add support for Linux on os/sys/posix termios.
2024-08-20 17:23:53 +02:00
Laytan 06fb500dfe make sure net.Network_Error is of size 8 2024-08-20 15:52:07 +02:00
Jeroen van Rijn 5ef58049dc Merge pull request #4114 from it-a-me/master
fix wiki link in the README.md
2024-08-20 14:27:47 +02:00
Laytan Laats 5b22bfa2b7 unify LB_ABI_INFO and LB_ABI_INFO_CTX 2024-08-20 14:07:47 +02:00
Laytan ca6ef95b03 add support for linux_riscv64 and freestanding_riscv64 2024-08-20 14:06:40 +02:00
it-a-me 53500699a9 README.md: Fix wiki link 2024-08-19 23:00:26 -07:00
Jeroen van Rijn 29838da782 Merge pull request #4111 from RoryO/simd-typo
fix simd var typo
2024-08-20 00:52:37 +02:00
Rory OConnell 97795ff3a2 fix simd var typo 2024-08-19 15:50:42 -07:00
Isaac Andrade 6df51b42a8 Fix termios NCCS size on linux. 2024-08-19 15:32:55 -06:00
Isaac Andrade 3228178d87 Add support for Linux on os/sys/posix termios. 2024-08-19 14:56:37 -06:00
Jeroen van Rijn 3fc1f6f1cd Merge pull request #4101 from Yawning/feature/index-byte-tweaks
core/bytes: Tweak `index_byte`/`last_index_byte`
2024-08-19 20:43:37 +02:00
gingerBill 2999c02f65 Fix random typo 2024-08-19 16:33:17 +01:00
gingerBill 9d7ab8d5ca Add strings.contains_space 2024-08-19 16:31:03 +01:00
gingerBill 2a0785037b Fix switch val in ptr 2024-08-19 12:19:45 +01:00
Yawning Angel 9e65e229d0 core/bytes: Tweak index_byte and last_index_byte
- Assume unaligned loads are cheap
- Explicilty use 256-bit or 128-bit SIMD to avoid AVX512
- Limit "vectorized" scanning to 128-bits if SIMD is emulated via SWAR
- Add a few more benchmark cases
2024-08-19 11:40:36 +09:00
Jeroen van Rijn 34a9e20531 Merge pull request #4108 from Feoramund/remove-deprecated-testing-log
Remove deprecated `log` procs from `core:testing`
2024-08-19 04:19:22 +02:00
Feoramund 0fa24ac3c4 Remove deprecated log procs from core:testing 2024-08-18 21:30:32 -04:00
Jeroen van Rijn 17eb0b5ee0 Merge pull request #4107 from Feoramund/add-digit-count
Add `core:math.count_digits_of_base`
2024-08-19 02:36:05 +02:00
Feoramund b49b80bdf9 Add test for count_digits_of_base 2024-08-18 20:14:14 -04:00
Feoramund 2906f2aa7e Add core:math.count_digits_of_base 2024-08-18 20:14:14 -04:00
Yeongju Kang f96991364a implement clock_settime, clock_getres and clock_nanosleep 2024-08-19 08:53:07 +09:00
Laytan 359a212a78 Merge pull request #4104 from laytan/find-llvm-config-through-brew
query brew for llvm-config location if possible
2024-08-19 00:41:06 +02:00
Laytan Laats ea7e8f075d query brew for llvm-config location if possible 2024-08-19 00:02:14 +02:00
gingerBill d99a6ad003 Add suggestion for ~uint(0) if cast(uint)-1 is done 2024-08-18 22:52:57 +01:00
gingerBill 95c3b8a8de Move assert to else branch 2024-08-18 22:45:26 +01:00
Laytan Laats ae41779366 remove redundant & 2024-08-18 21:10:21 +02:00
Laytan bb3f848b4a Merge pull request #4103 from laytan/wait-shared-on-macos-10-15
UL_COMPARE_AND_WAIT_SHARED is macOS 10.15+
2024-08-18 19:38:52 +02:00
gingerBill a51b9c6fb0 Merge branch 'master' of https://github.com/odin-lang/Odin 2024-08-18 18:37:45 +01:00
gingerBill 8e52a52580 Cache the paddding filler type 2024-08-18 18:37:40 +01:00
Laytan Laats b7b3ada3b1 UL_COMPARE_AND_WAIT_SHARED is macOS 10.15+ 2024-08-18 19:31:52 +02:00
Laytan 9a895a318c Merge pull request #4102 from laytan/wasm-lshrti3
Implement lshrti3 on wasm
2024-08-18 17:18:05 +02:00
Laytan Laats b2e64b7ce0 implement lshrti3 on wasm 2024-08-18 17:09:57 +02:00
Yawning Angel 7020e9b66a core/simd: Add IS_EMULTATED so there is one place to look for potatos 2024-08-18 22:52:39 +09:00
gingerBill f49ebae956 Correct lbAddr_SoaVariable logic 2024-08-18 12:37:15 +01:00
gingerBill 0e82a46047 Fix #3999 2024-08-18 12:35:25 +01:00
gingerBill c4e0cbcd87 Fix #4005 2024-08-18 12:21:35 +01:00
gingerBill f82bf6cd42 Fix #4022 2024-08-18 12:13:52 +01:00
gingerBill 60b2979cfd Fix #4024 2024-08-18 12:10:46 +01:00
gingerBill 17740966e5 Fix #4040 2024-08-18 12:06:58 +01:00
gingerBill 5c06fcd346 Fix #4064 2024-08-18 12:00:27 +01:00
gingerBill 22a82e73d6 Fix #3976 2024-08-18 11:45:27 +01:00
Jeroen van Rijn bbb5593f87 Merge pull request #4098 from jolson88/raygui/vertical-text-alignment
(raygui) Restores vertical text alignment broken after 4.0 migration
2024-08-17 22:29:38 +02:00
Jason Olson d00057c803 Add missing trailing comma 2024-08-17 13:23:42 -07:00
Jason Olson acfd9dcd1b Restores vertical text alignment broken after 4.0 migration
A series of changes between raygui 3.6 and 4.0 were that various text box
properties were moved from the text box specific properties up into the
extended default control properties. This change corrects the various
property enums to match the raygui 4.0 API.

One additional aspect of this change was rolling back a previous commit
made to this vendor file that changed the signature of GuiSetStyle and
GuiGetStyle from using a c.int as property value to a more strongly-defined
GuiControlProperty enum. Unfortunately, this breaks the raygui API by
disallowing the use of various control-specific extended properties due to
how the enums are built.
2024-08-17 12:35:50 -07:00
Jeroen van Rijn 9553bc3689 If missing type is newline, print "newline", not \n
Turns:

W:/Odin/bug/bug.odin(3:27) Syntax Error: Expected a type, got '
'
        Storage :: distinct map[]

Into:

W:/Odin/bug/bug.odin(3:27) Syntax Error: Expected a type, got newline
        Storage :: distinct map[]
2024-08-17 17:25:52 +02:00
Jeroen van Rijn ebbb70f11d Error if missing map key type
Fixes #4096
2024-08-17 17:12:27 +02:00
Laytan Laats 142bda2804 posix: start on process API 2024-08-17 15:48:01 +02:00
Jeroen van Rijn 478f529744 Merge pull request #4094 from amad00r/fix-nil-logger
Fix log unnecessary allocations
2024-08-17 01:50:13 +02:00
gingerBill 536a342873 Merge pull request #4092 from laytan/fix-open-bindings
fix `open` bindings
2024-08-17 00:22:46 +01:00
Amadeu Moya 43dc7704a5 Fix log unnecessary allocations 2024-08-17 00:37:01 +02:00
Laytan Laats e8933e43ec add haiku to unsupported time file 2024-08-16 23:18:59 +02:00
Laytan Laats f7d7d65bc0 fix open bindings
`open` specifies the `mode` argument as vararg (presumably to make it
optional). varargs actually have rules about casting, in this case the
rule that any integer arg of size <= 4 has to be casted to `i32` before
passing it.

Not doing that implicit cast makes the permissions wrong or not apply at
all.
2024-08-16 22:54:53 +02:00
Jeroen van Rijn 970dc7a1f2 Merge pull request #4091 from Feoramund/fix-darwin-os-open
Check if file open-mode is `O_CREATE` on Darwin before forcing chmod
2024-08-16 20:31:22 +02:00
Feoramund a07878be71 Check if file open-mode is O_CREATE on Darwin before forcing chmod
Fixes #4087
2024-08-16 14:08:55 -04:00
Jeroen van Rijn 14e207088a Merge pull request #4088 from Kelimion/benchmark
Improve benchmarks.
2024-08-16 17:16:59 +02:00
Jeroen van Rijn 6c46c9e04b Improve benchmarks. 2024-08-16 17:00:16 +02:00
gingerBill 40b8150a23 Minor clean ups 2024-08-16 12:47:23 +01:00
gingerBill 31bb3dc4f0 Merge pull request #3971 from jasonKercher/os2-process-linux
os2 process linux implementation
2024-08-16 12:38:27 +01:00
gingerBill 65ce7687d7 Merge pull request #4004 from Skytrias/orca-odin-bindings
Add autogenerated orca bindings and macros from laytan
2024-08-16 12:37:36 +01:00
Laytan 6fc39c1b5d Merge pull request #4075 from yay/more-foundation-bindings
More Foundation bindings.
2024-08-16 13:08:15 +02:00
jason 07a9c69714 update core:filepath's clean, join and split_list to return optional Allocator_Errors 2024-08-16 01:48:27 -04:00
Vitalii Kravchenko 004036dc59 More Foundation bindings. 2024-08-16 00:00:29 +01:00
Laytan d91fa162d8 Merge pull request #3280 from beaumccartney/shm_syscalls
add shm_open and shm_unlink syscalls for darwin
2024-08-15 17:08:41 +02:00
gingerBill 6e91f6ab31 Merge pull request #4081 from DerTee/master
fix error handling in os2.read_entire_file_from_file()
2024-08-14 22:12:06 +01:00
gingerBill b16d5198a3 Merge pull request #4082 from FourteenBrush/master
Fix 'odin [run|test] --' giving a compiler out of bounds
2024-08-14 22:11:55 +01:00
FourteenBrush 12813e5d48 Fix 'odin [run|test] --' giving a compiler out of bounds 2024-08-14 21:37:40 +02:00
DerTee 6422e49255 fix error handling in os2.read_entire_file_from_file()
even when an error in file_size() happened, os2.ERROR_NONE was returned
2024-08-14 17:30:02 +02:00
Jeroen van Rijn f7234e2ed3 Allow ODIN_TEST_LOG_LEVEL override when -debug. 2024-08-14 16:29:51 +02:00
gingerBill e810c3eace Merge pull request #4012 from laytan/posix
core:sys/posix and core:os/os2 based on it (for darwin, netbsd, freebsd and openbsd)
2024-08-14 15:10:31 +01:00
gingerBill 18b6af1858 Minor clean up of comments 2024-08-14 14:15:20 +01:00
gingerBill 03dd38f203 Minor changes to vendor:ENet 2024-08-14 14:09:36 +01:00
gingerBill eb6f2078cf Add fmt:"v,extensions_count" tags to many struct fields 2024-08-14 14:03:41 +01:00
gingerBill df61096317 Improve doc comments for vendor:ggpo 2024-08-14 13:55:25 +01:00
gingerBill 8abe054665 Merge branch 'master' of https://github.com/odin-lang/Odin 2024-08-14 13:02:28 +01:00
gingerBill 324d9c2284 Fix doc writer bug caused by using an iterator rather than a for loop 2024-08-14 13:02:23 +01:00
Laytan Laats f657b4cc0c time: use assert_contextless in wasi implementation 2024-08-14 13:27:58 +02:00
gingerBill c98c95fcf0 Add require_results and change some of the wrapper to return a slice 2024-08-14 11:29:23 +01:00
gingerBill fd5376ba88 Allow @(require_results) on foreign blocks 2024-08-14 11:28:49 +01:00
gingerBill 78fa675c1a Add assert_contextless, panic_contextless, unimplemented_contextless 2024-08-14 11:18:24 +01:00
gingerBill 4c19f507ff Merge pull request #4074 from odin-lang/vendor/box2d
`vendor:box2d`
2024-08-14 11:15:34 +01:00
gingerBill 651122e9db Fix foreign import paths 2024-08-14 11:01:54 +01:00
gingerBill d1e114742e Add deprecated and require_results attributes to math_functions.odin 2024-08-14 10:55:40 +01:00
Laytan 29a6959a56 Merge pull request #2977 from jakubtomsu/disallow-variadic-param-default
Report error when a variadic procedure parameter has a default value
2024-08-14 11:55:09 +02:00
gingerBill 491def9d5b Fix paths for amd64 targets 2024-08-14 10:50:53 +01:00
gingerBill 427c48221d Clean up foreign import code for library path determination 2024-08-14 10:28:07 +01:00
gingerBill 1c97739ca3 Merge branch 'vendor/box2d' of https://github.com/odin-lang/Odin into vendor/box2d 2024-08-14 10:18:41 +01:00
gingerBill 0b26115805 Improve presentation 2024-08-14 10:18:36 +01:00
gingerBill 1c8672ac6c Merge pull request #4078 from funkkiy/fix-rodata-index
Error if assigning to `rodata` variable with index
2024-08-14 09:41:35 +01:00
jason 0f052dbde7 os2/process_linux: improve error handling, use pidfd where possible, remove usage of fmt 2024-08-14 00:45:25 -04:00
Davi 4bb51249d1 Error if assigning to rodata variable with index 2024-08-13 23:28:34 -03:00
Laytan Laats e29f0a0f40 os2: dup the file descriptor before fdopendir 2024-08-14 01:45:24 +02:00
Laytan Laats f837e35f4b os2: fix bad free for posix file closure 2024-08-14 01:45:24 +02:00
Laytan Laats 61ee2efa35 os2: just use runtime._heap_allocator_proc instead of a copy for posix 2024-08-14 01:45:24 +02:00
Laytan Laats e94c4e1e18 posix: remove the is_temp things that prevented use-after-frees
https://github.com/odin-lang/Odin/commit/d0709a7de21efded4625167dbff4a7dd13d561b4
fixes those another way.
2024-08-14 01:45:24 +02:00
Laytan Laats b07d0b38b1 os2: improve absolute/full path handling for posix 2024-08-14 01:45:23 +02:00
Laytan Laats a73677d21a os2: nice != priority 2024-08-14 01:44:37 +02:00
Laytan Laats 67ea7bb65a posix: address some freebsd feedback 2024-08-14 01:44:37 +02:00
Laytan Laats 175f5b0bb1 os2: don't rely on PATH_MAX in posix read_directory implementation 2024-08-14 01:44:37 +02:00
Laytan Laats 939ba4cf08 os2: fix leak and always close directory 2024-08-14 01:44:37 +02:00
Laytan Laats f00f68ef6f posix/os2: fix test and add back in removed temp guard 2024-08-14 01:44:37 +02:00
Laytan Laats de9abe1f7b os2: skip . and .. in read dir 2024-08-14 01:44:37 +02:00
Laytan Laats bd808f9ec6 os2: fix wiping results with temp allocator guard 2024-08-14 01:44:37 +02:00
Laytan Laats 7474db6a34 os2: fix lstat logic 2024-08-14 01:44:37 +02:00
Laytan Laats 00eb702c4a os2: implement the iterator based read directory 2024-08-14 01:44:37 +02:00
Laytan Laats ea5783c2ac os2: fixes after rebasing 2024-08-14 01:44:37 +02:00
Laytan Laats e05fddc001 posix: fix file type checks in stat 2024-08-14 01:44:37 +02:00
Laytan Laats 406e60f5dd posix: revert change to os that was done for testing 2024-08-14 01:44:37 +02:00
Laytan Laats 5115aee23f posix: actually fix netbsd test 2024-08-14 01:44:37 +02:00
Laytan Laats 72220a855f posix: fix write error check 2024-08-14 01:44:37 +02:00
Laytan Laats 4a61bac100 posix: fix test on netbsd 2024-08-14 01:44:37 +02:00
Laytan Laats 726891588f posix: more tests 2024-08-14 01:44:37 +02:00
Laytan Laats 2a5ceff667 posix: move doc 2024-08-14 01:44:37 +02:00
Laytan Laats 9e2c5acb9d os2: fix bit checks 2024-08-14 01:44:37 +02:00
Laytan Laats 7c9ca60ff0 mem/virtual: support the BSDs 2024-08-14 01:44:37 +02:00
Laytan Laats 379cd6fe66 os2: cleanup 2024-08-14 01:44:37 +02:00
Laytan Laats ffff3c3c88 posix: fix foreign import of dl for free/netbsd 2024-08-14 01:44:37 +02:00
Laytan Laats a4d459f651 os2: initial implementation for Darwin&BSDs, process API is only thing incomplete 2024-08-14 01:44:37 +02:00
Laytan Laats ff0ca0bd53 os2: make config directory on darwin also ~/.config, it is the proper place 2024-08-14 01:44:37 +02:00
Laytan Laats 07b9f7d280 os2: fix read_entire_file bad logic 2024-08-14 01:44:37 +02:00
Laytan Laats 9f80191f60 os2: add default make_directory permissions 2024-08-14 01:44:37 +02:00
Laytan Laats efe68c2e24 posix: add package 2024-08-14 01:44:35 +02:00
Laytan 3847d03248 Merge pull request #3281 from erjohnson/patch-1
Update mem doc example formatting
2024-08-14 00:10:03 +02:00
Laytan Laats bb54a0a972 fix whitespace 2024-08-14 00:08:46 +02:00
Laytan Laats ac68a9d52c update MacOS releases 2024-08-14 00:00:50 +02:00
Laytan Laats d4d46df2fc box2d: add build script and MacOS libraries 2024-08-13 22:15:31 +02:00
gingerBill 660b6ff0f1 Add vendor:box2d to examples/all 2024-08-13 17:08:31 +01:00
gingerBill 9ccaca7f1a Minor style change 2024-08-13 17:01:55 +01:00
gingerBill 926c419ef8 Change .lib to be /MT compatible; Fix comments 2024-08-13 16:58:35 +01:00
gingerBill 22b32ab0fa Use intrinsics.has_target_feature 2024-08-13 16:35:28 +01:00
gingerBill 40361f877e Add libraries for windows 2024-08-13 16:34:31 +01:00
gingerBill f2ba3da895 Create bindings for box2d
Currently missing lib binaries
2024-08-13 16:18:24 +01:00
Laytan 55be3e60a0 Merge pull request #3125 from marcs-feh/master
sys/linux: Add binding to ioctl syscall + standard fd constants.
2024-08-13 15:30:50 +02:00
gingerBill 62911539cd Minor style change 2024-08-13 14:27:25 +01:00
Laytan c7af8af76a Update core/sys/linux/sys.odin 2024-08-13 15:22:35 +02:00
gingerBill e3d5bbe62c Merge pull request #4065 from laytan/fix-max-alignments
fix max alignments
2024-08-13 14:09:45 +01:00
gingerBill 2584c6bcd7 Merge pull request #4069 from zen3ger/1738-aliased-procedure-resolution
Fix alias handling of procedures
2024-08-13 14:07:51 +01:00
gingerBill 66d3082a9a Merge pull request #4056 from laytan/re-enable-runtime-wasm-stuff
re-enable some wasm things in runtime
2024-08-13 14:04:19 +01:00
gingerBill 09a07bd7e0 Merge pull request #4055 from laytan/time-wasi
time: wasi implementation
2024-08-13 14:03:02 +01:00
gingerBill 848f7e117f Merge pull request #4050 from IllusionMan1212/egl-procs
vendor/egl: added a few more egl procedures and constants
2024-08-13 14:01:20 +01:00
gingerBill d93364ce52 Merge pull request #4049 from IllusionMan1212/xrandr-xinput-xfixes
vendor/x11: added a few procedures for xrandr, xinput, and xfixes
2024-08-13 14:00:08 +01:00
gingerBill 4c4f24b5f4 Merge pull request #4041 from zen3ger/1079-parametric-struct-from-other-package
Check if procedure parameter type declares polymorphic args
2024-08-13 13:59:06 +01:00
Jeroen van Rijn 069ad446cd Merge pull request #4070 from Feoramund/test-runner-mem-fail-as-error
Let memory failures be errors in the test runner
2024-08-13 13:50:46 +02:00
Jeroen van Rijn 02b4bb8491 Merge pull request #4072 from laytan/fix-32-bit-math-round
fix type hint propagation for shift
2024-08-13 00:34:19 +02:00
Laytan Laats 2808ecc5b6 remove panic workaround 2024-08-12 23:48:36 +02:00
Laytan Laats a1d518442a fix type hint propogation for shift
Fixes #3856
2024-08-12 23:39:07 +02:00
Jeroen van Rijn 0d916a659e Merge pull request #4053 from Feoramund/fix-gitignore
Fix `.gitignore`
2024-08-12 21:34:26 +02:00
Feoramund 3a32250b80 Add .gitignore for tests directory 2024-08-12 15:16:52 -04:00
Jeroen van Rijn 053e65a1c8 Merge pull request #4071 from andreas-jonsson/andreas-jonsson-patch-2
Use another URL for pkgsrc on CI
2024-08-12 20:58:41 +02:00
Andreas T Jonsson 7af0291c7d Try use another arch URL for pkgsrc 2024-08-12 20:27:20 +02:00
Feoramund 0af025d056 Add explicit copyright info to core:testing 2024-08-12 14:16:22 -04:00
Roland Kovacs 9eb7186cda Fix alias handling of procedures
An incorrect memmove when overriding entities caused multiple ones to point to
the same procedure with incomplete variant data, resulting in later hiting a
compiler assertion.

Introduced delayed type checking for procedure aliases, as it was masked by
the previous error in the override logic.
2024-08-12 19:52:42 +02:00
Laytan d68cc41782 Merge pull request #4068 from laytan/fix-read-dir-closing-given-fd
fix `os.read_dir` closing the given file descriptor
2024-08-12 19:23:48 +02:00
Laytan fb09ec06d3 Merge pull request #4066 from Tetralux/fmt-bitfields-pointers
[fmt] Add bit fields to the pointer printing logic
2024-08-12 19:14:15 +02:00
Laytan Laats a4ac3cc6e8 fix os.read_dir closing the given file descriptor 2024-08-12 18:51:27 +02:00
Tetralux 4f56822204 [fmt] Add bit fields to the pointer printing logic
core:fmt prints pointers to structs as `&StructName{ ... }` but `bit_field`s are currently printed
the same as rawptrs (`0xAABBCCDDEEFF` only).

This commit changes that so they behave the same as structs and unions.
2024-08-12 16:25:22 +00:00
Laytan Laats f22ff21039 fix max alignments 2024-08-12 17:05:51 +02:00
Laytan b71e0c2e36 Merge pull request #4059 from laytan/loop-write-entire-file
loop write_entire_file to write more than MAX_RW
2024-08-12 13:54:46 +02:00
Laytan fd9a008e1e Merge pull request #4058 from laytan/fix-cvararg-bitset
fix c_vararg bit_set
2024-08-12 13:54:28 +02:00
Laytan 450fc3ec77 Merge pull request #4060 from laytan/support-field-tag-bitsets-in-core-odin
core/odin: support field tags on bit_field fields
2024-08-12 13:53:33 +02:00
Laytan 0a118a14ab Merge pull request #4061 from laytan/fix-fmt-maybe-pointer-detection
fix `type_info_union_is_pure_maybe` only working with regular pointers
2024-08-12 13:53:17 +02:00
Feoramund f42a22369e Fix wrong define name in test runner log messages 2024-08-11 23:01:28 -04:00
Feoramund 675add4d90 Optionally treat memory failures as errors in the test runner
Enable with `-define:ODIN_TEST_FAIL_ON_BAD_MEMORY=true`.
2024-08-11 22:59:20 -04:00
Jeroen van Rijn 1761802330 Merge pull request #4062 from laytan/fix-switch-over-internal-pointer-union
fix type switching over internal pointer union
2024-08-12 00:25:47 +02:00
Laytan Laats 99aa0d3a35 fix type switching over internal pointer union
Fixes #3947
2024-08-12 00:02:05 +02:00
Laytan Laats dec97cbddb fix type_info_union_is_pure_maybe only working with regular pointers
Fixes #3996
2024-08-11 21:07:21 +02:00
Laytan Laats f0840ed24e core/odin: support field tags on bit_field fields
Fixes #4044
2024-08-11 20:59:54 +02:00
Laytan b9e68ee3c1 Merge pull request #4054 from Feoramund/zlib-reverse-bits
Use `intrinsics.reverse_bits` in `core:compress/zlib`
2024-08-11 17:42:28 +02:00
Laytan Laats d6336e7252 add orca to examples/all for docs 2024-08-11 17:35:19 +02:00
Laytan Laats c6a0d302b3 loop write_entire_file to write more than MAX_RW
Fixes #4042
2024-08-11 17:27:54 +02:00
Laytan Laats 26fa3aca44 fix copy-paste error in make docs 2024-08-11 17:09:26 +02:00
Laytan Laats e3f375afd8 fix c_vararg bit_set
Fixes #4051
2024-08-11 17:00:49 +02:00
Jeroen van Rijn 8a67221bd4 Merge pull request #4057 from asibahi/patch-1
typo fix
2024-08-11 13:35:10 +02:00
Abdul Rahman Sibahi 67251ad5b8 typo fix 2024-08-11 14:30:48 +03:00
Laytan 938e81e341 sys/orca: add missing using 2024-08-10 23:59:51 +02:00
Laytan Laats f5fe0de0fd add clarity for diverging mismatch error 2024-08-10 23:34:35 +02:00
Laytan Laats 7fd8b9c55b re-enable some wasm things in runtime
No idea why the floattidf procs are bodged to return 0, does somebody
know? I have just enabled the original codepath, if nobody knows I
suggest just enabling it and see if we get complaints, it works on all
wasm stuff I tried.

The linkage being set to "internal" instead of "strong" is actually
causing problems in my projects which is what prompted looking at this
in the first place, some of these functions were actually needed but not
added/used because they had internal linkage. This only happens on
bigger projects (or just when using f16?).

Unfortunately `git blame` gave me this generic commit: https://github.com/odin-lang/Odin/commit/94bad4d7861c78b9e7191ec0c3114861a1536d5c#diff-fb9f42022cb95efa59d16813546b8cb310234428c85edfabf09b1425c9dc46af
2024-08-10 23:10:30 +02:00
Laytan Laats a2cd763dbb time: wasi implementation 2024-08-10 23:01:31 +02:00
Feoramund cf8f6afeff Use intrinsics.reverse_bits in core:compress/zlib 2024-08-10 15:29:44 -04:00
Feoramund afbdc78f85 Fix .gitignore
- Remove all-encompassing `benchmark`
- Add exception for `core:simd/x86`
2024-08-10 15:16:12 -04:00
Laytan Laats 6918d8aaa6 possibly fix init_core_type_info race condition 2024-08-10 21:03:40 +02:00
Jeroen van Rijn e226d37803 Merge pull request #4023 from Feoramund/simd-index
Vectorize `index_byte`
2024-08-10 21:01:41 +02:00
Feoramund 4f816aabb3 Use SIMD_SCAN_WIDTH constant in core:bytes test 2024-08-10 13:54:12 -04:00
Laytan Laats d98f848247 fix debug compiler build message not ending output with a newline 2024-08-10 19:07:30 +02:00
Jeroen van Rijn 1242b6e82f Improve slice.binary_search_by 2024-08-10 18:26:59 +02:00
Jeroen van Rijn 9759d56c81 Merge pull request #4003 from Yawning/feature/crypto-improvements
core:crypto: Various improvements
2024-08-10 17:17:00 +02:00
Laytan d73ad8eb1e Merge pull request #4046 from laytan/cbor-fixes
encoding/cbor: various fixes
2024-08-10 17:02:41 +02:00
jason a52f7c129f stop trying to handle child pipe read errors in process_start 2024-08-10 09:13:07 -04:00
jason e54d6e5a11 Ignore process_open errors in process_start. This enforces a contract
with the user that any process returned without error must eventually be
waited on.
2024-08-10 09:03:34 -04:00
jason f7a73b9555 fix error handling; close read end of the child pipe instead of the write end twice 2024-08-10 08:55:40 -04:00
Feoramund 9d2b4b2f03 Simplify core:bytes test 2024-08-10 08:13:22 -04:00
Feoramund 5d5addd48f Set SIMD_SCAN_WIDTH based on size_of(uintptr) 2024-08-10 07:43:14 -04:00
Feoramund c69fa87d53 Merge core:simd/util into core:bytes 2024-08-10 07:17:03 -04:00
Jeroen van Rijn bf53d2f6db Fix time.precise_clock on 32-bit platforms. 2024-08-10 12:44:40 +02:00
Jeroen van Rijn d267735d99 Fixed time.precise_clock 2024-08-10 12:35:58 +02:00
IllusionMan1212 554b0e5bf7 vendor/x11: added a few procedures for xrandr, xinput, and xfixes 2024-08-10 12:06:52 +02:00
Yawning Angel ba1ad82c2b core/crypto/aead: Initial import 2024-08-10 18:32:37 +09:00
Yawning Angel 38aea1f907 core/crypto/aes,chacha20poly1305: Add require_results to open 2024-08-10 18:32:37 +09:00
Yawning Angel b381791f42 core/crypto/chacha20: Change API terminology to be consistent with AES 2024-08-10 18:32:37 +09:00
Yawning Angel 14ceb0b19d core/crypto/chacha20poly1305: Support AEAD_XChaCha20_Poly1305
IETF-draft flavor (32-bit counter) though this makes no practical
difference.
2024-08-10 18:32:37 +09:00
Yawning Angel 8efc98ce90 core/crypto/chacha20poly1305: Change the interface to match GCM 2024-08-10 18:32:37 +09:00
Yawning Angel 1f3107e693 core/crypto/chacha20: Use 128-bit/256-bit SIMD 2024-08-10 18:32:37 +09:00
Yawning Angel 708f053fe6 core/crypto/aes: Use NIST terminology for the IV 2024-08-10 18:32:37 +09:00
Yawning Angel ac7f44b1b8 core/crypto/aes: Slightly tweak GHASH to look less spooky 2024-08-10 18:32:37 +09:00
Yawning Angel b1d6e4139e core/crypto/aes: Disable bounds checking for the CTR loops 2024-08-10 18:32:37 +09:00
Yawning Angel dfc4df9807 core/crypto/_aes/hw_intel: Use a constant for the PSHUFB indicies 2024-08-10 18:32:37 +09:00
Yawning Angel b9293334ca core/crypto/ed25519: Rename a member for clarity
This better matches the spec.
2024-08-10 18:32:37 +09:00
Yawning Angel b68311d777 core/crypto/hash: Make the _to_buffer routines return the hash slice
Quality of life improvement.
2024-08-10 18:32:37 +09:00
Yawning Angel c0f9655ec4 test/core/crypto: Minor changes to AES related tests
- Test against the non-standard GCM nonce length vectors
- Fix the CTR mode test to match the comment

Correctness was fine without this change.
2024-08-10 18:32:37 +09:00
IllusionMan1212 7875e4a1ab vendor/egl: added a few more egl procedures and constants 2024-08-10 10:21:03 +02:00
Jeroen van Rijn be7a1f671c Revert "Add time.precise_clock_from_time + time.precise_clock_from_duration"
This reverts commit c9ca192f33.
2024-08-10 03:26:09 +02:00
Jeroen van Rijn c9ca192f33 Add time.precise_clock_from_time + time.precise_clock_from_duration 2024-08-10 03:23:08 +02:00
Feoramund e7e7fe766a Add test for misaligned data to core:simd/util suite 2024-08-09 18:54:04 -04:00
Feoramund 0d29cc3375 Use for x in y construct for bytes iteration
This cannot be applied to the `strings` version, as that would cause a
rune-by-rune iteration, not a byte-by-byte one.
2024-08-09 18:54:04 -04:00
Feoramund c8a62ee4ec Make simd_util index procs contextless where applicable 2024-08-09 18:54:04 -04:00
Feoramund 12dd0cb72a Simplify and make simd_util cross-platform
This new algorithm uses a Scalar->Vector->Scalar iteration loop which
requires no masking off of any incomplete data chunks.

Also, the width was reduced to 32 bytes instead of 64, as I found this
to be about as fast as the previous 64-byte x86 version.
2024-08-09 18:54:04 -04:00
Laytan Laats 912f99abc8 encoding/cbor: various fixes
- "null" is the proper way to represent the nil value in the diagnostic
  format
- hex encoding in diagnostic format was wrong
- struct keys weren't sorted the right deterministic way
2024-08-09 21:56:54 +02:00
jason baacc512e3 fix child pipe in process_start 2024-08-09 15:21:11 -04:00
Jeroen van Rijn c5ed7083d2 Disable NetBSD CI 2024-08-09 19:44:51 +02:00
Jeroen van Rijn d69e0bfa00 NetBSD vm fix. 2024-08-09 19:37:26 +02:00
Jeroen van Rijn fa6f343261 Remove unused import. 2024-08-09 19:06:50 +02:00
jason c4d43bbab0 os2 linux process_wait rework; add Sig_Child_Code to sys/linux bits 2024-08-09 09:16:44 -04:00
Jeroen van Rijn cc24d2de3e Merge pull request #3810 from Feoramund/freebsd-core-net
Port `core:net` to FreeBSD
2024-08-09 09:50:05 +02:00
Jeroen van Rijn bc6deab175 echo -> printf for build_odin.sh message 2024-08-09 09:46:45 +02:00
Laytan b5a612202f Merge pull request #4036 from laytan/master
add debug build message and align more with build.bat
2024-08-08 22:21:17 +02:00
Jeroen van Rijn 1e09ff3b2e Merge pull request #4043 from Kelimion/expect_leak_or_bad_free
Allow testing for intentional leaks in test runner
2024-08-08 21:40:17 +02:00
Jeroen van Rijn 933f9f9bd1 Enable test leak = fatal on CI. 2024-08-08 21:31:30 +02:00
Jeroen van Rijn b82cfc5f15 Fix shoco heisenleak 2024-08-08 21:15:59 +02:00
Jeroen van Rijn a05b73c632 Keep -vet happy when mem tracking is disabled. 2024-08-08 21:02:35 +02:00
Jeroen van Rijn 4d27898418 Use test runner's own tracking allocator. 2024-08-08 20:58:25 +02:00
Jeroen van Rijn 80d1e1ba82 Allow testing for intentional leaks in test runner
Adds `expect_leak_or_bad_free :: proc(t: ^T, client_test: proc(t: ^T), verifier: Memory_Verifier_Proc)`.

It sets up its own `Tracking_Allocator`, runs the `client_test`, and then calls the `verifier` procedure.
The verifier can then inspect the contents of the tracking allocator and call `testing.expect*` as sensible for the test in question.

Any allocations are then cleared so that the test runner doesn't itself complain about leaks.

Additionally, `ODIN_TEST_LOG_LEVEL_MEMORY` has been added as a define to set the severity of the test runner's memory tracker. You can use `-define:ODIN_TEST_LOG_LEVEL_MEMORY=error` to make tests fail rather than warn if leaks or bad frees have been found.
2024-08-08 20:41:32 +02:00
Roland Kovacs dda89a69bf Check if procedure parameter type declares polymorphic args
When a procedure parameter's type was declared in an imported package the type
checker correctly resolved to the parametric type, but it did not check if the
expression that refers to that type conforms to a polymorphic type declaration.

This error was not detected if the procedure was unused, since it was marked as
polymorphic, where further type check is done on instantiation.
2024-08-08 19:50:05 +02:00
Jeroen van Rijn f328929939 Merge pull request #4038 from Hyrtwol/core-sys-windows-rawinput-code
Core sys windows rawinput code
2024-08-08 18:23:02 +02:00
Thomas la Cour 3d0519fe6c trim whitespace 2024-08-08 18:05:41 +02:00
Thomas la Cour a4eeb6ed02 rawinput code 2024-08-08 18:03:59 +02:00
Jeroen van Rijn 94c62fb630 Fix typo. 2024-08-08 18:01:09 +02:00
Jeroen van Rijn a7fe9eec73 Merge pull request #4037 from Kelimion/symlink_test
Allow symlink test to work irrespective of git settings.
2024-08-08 17:56:05 +02:00
Jeroen van Rijn d93f3c63d8 Rename package to test_core_os to fit with the rest of test_* 2024-08-08 17:49:08 +02:00
Jeroen van Rijn ada3df303e Allow symlink test to work irrespective of git settings. 2024-08-08 17:46:00 +02:00
Laytan Laats 8b98fff98e add debug build message and align more with build.bat
1. if ran without choosing a build type (just `make` or
   `build_odin.sh`), print out a message about it being a debug build
2. Add `make release-native` alongside `make release_native` to align
   with `build_odin.sh release-native`
3. Only run the demo if it is a debug build (just like `build.bat`)
2024-08-08 15:33:40 +02:00
jason c3ba8fbd09 add child pipe for reporting post-fork errors 2024-08-08 08:56:29 -04:00
Jeroen van Rijn 4b9ca39522 Merge pull request #4035 from karl-zylinski/build-release-hint
Added a hint at end of build.bat about release mode when building in debug mode
2024-08-08 14:48:48 +02:00
Karl Zylinski 26633bbce6 Added a hint at end of build.bat about release mode when building in debug mode. 2024-08-08 14:15:32 +02:00
jason 9625798513 merge commit 2024-08-07 23:27:45 -04:00
Jeroen van Rijn 796feeead9 Remove LLVM copy from nightly. 2024-08-07 22:12:23 +02:00
Jeroen van Rijn 2bf055ec6e Delete empty file after access check. 2024-08-07 19:38:36 +02:00
Laytan Laats c9b69d76b0 text/edit: fix undo_state_push wrong builder check 2024-08-07 17:21:56 +02:00
Jeroen van Rijn 69a15ca5b6 Don't copy LLVM shared object on Linux
We copy the LLVM shared object when building Odin on Linux. Contrary the comment in `build_odin.sh`,
this is unnecessary, and Odin can be compiled and itself compile things just fine without this step.

This is then packaged up at release and leads to #4019 and #4033. The Linux release builds are built
on Ubuntu and not strictly supported on other Linux distributions. Building from source is preferred.
2024-08-07 14:50:45 +02:00
Laytan Laats 6fe938b946 darwin: add setAllowedFileTypes binding for open panels 2024-08-06 21:42:33 +02:00
Laytan Laats e5a478d393 wgpu: fix examples after changing color to an array 2024-08-06 21:42:33 +02:00
Feoramund 793811b219 Add simd_util to examples/all 2024-08-06 15:19:05 -04:00
Feoramund 0418d27bdf Add benchmarks for vectorized index_* procs 2024-08-06 15:19:05 -04:00
Feoramund 28c98c2e7a Add tests for vectorized index_* procs 2024-08-06 15:19:05 -04:00
Feoramund f66fcd9acb Use vectorized index_* procs in core 2024-08-06 15:19:05 -04:00
Feoramund 8deeb40e5d Add vectorized index_byte and last_index_byte 2024-08-06 15:19:01 -04:00
gingerBill 39d557bcb4 Merge pull request #4032 from Feoramund/fix-intrinsic-wording
Fix SIMD intrinsics wording
2024-08-06 20:13:10 +01:00
Feoramund e27a424f4d Swap reduce_any and reduce_all
`llvm.vector.reduce.or` will return true if any lane is true.
`llvm.vector.reduce.and` will return true if all lanes are true.
2024-08-06 14:50:34 -04:00
Feoramund 7a367c9c08 Fix documented names of a few SIMD procedures 2024-08-06 14:49:56 -04:00
Laytan 4423aac3de Merge pull request #4031 from RilleP/bit-field-closing-brace-fix
Fix missing closing brace for Bit_Field in core:odin/parser
2024-08-06 20:49:49 +02:00
gingerBill 94ded29b5f Merge pull request #4030 from Kelimion/struct_field_count
Add `reflect.struct_field_count` that returns the number of fields in a struct type
2024-08-06 18:56:24 +01:00
Rikard Petré 6a6f078186 Fix missing closing brace for Bit_Field in core:odin/parser 2024-08-06 19:48:38 +02:00
gingerBill bed18a17e6 Bodge: Improve aligned_resize logic 2024-08-06 11:22:34 +01:00
Jeroen van Rijn 17ebaffce8 Update comment. 2024-08-05 22:12:22 +02:00
Jeroen van Rijn 4902288a5a Add reflect.struct_field_count that returns the number of fields in a struct type
Example:
```odin
package struct_count_example

import "core:fmt"
import "core:reflect"
import "core:dynlib"

Foo :: struct{
	one: int,
	two: f32,
}

Bar :: struct {
	three: int,
	four:  bool,
	five:  f64,
}

Game_Api :: struct {
	init:      proc(api: ^Game_Api),
	update:    proc(api: ^Game_Api),

	using foo: Foo,
	bar:       Bar,

	// Private stuff
	reload_count: int,
	__handle:     rawptr,
}
API_PRIVATE_COUNT :: 2

game_api: Game_Api

main :: proc() {
	fmt.printfln("Game_Api, .Top:       %v", reflect.struct_field_count(Game_Api))              // 6
	fmt.printfln("Game_Api, .Using:     %v", reflect.struct_field_count(Game_Api, .Using))      // 8
	fmt.printfln("Game_Api, .Recursive: %v", reflect.struct_field_count(Game_Api, .Recursive))  // 11

	symbols_loaded, _  := dynlib.initialize_symbols(&game_api, "game.dll")
	symbols_expected   := reflect.struct_field_count(Game_Api) - API_PRIVATE_COUNT

	if symbols_loaded == -1 {
		fmt.eprintln("Couldn't load game.dll")
		return
	} else if symbols_loaded != symbols_expected {
		fmt.eprintfln("Expected %v symbols, got %v", symbols_expected, symbols_loaded)
		return
	}
}
```
2024-08-05 22:04:16 +02:00
Laytan a1c3c38f04 Merge pull request #4029 from Feoramund/fix-darwin-sigpipe-send
Prevent `SIGPIPE` on Darwin when writing to a closed `core:net` socket
2024-08-05 19:26:16 +02:00
Feoramund 4c0ab09c9a Handle EPIPE in Darwin core:net 2024-08-05 13:15:08 -04:00
Feoramund 6cc7f3b451 Add FreeBSD Accept_Error.Would_Block alias 2024-08-05 13:00:44 -04:00
Feoramund 3512d7c672 Move Darwin MSG_NOSIGNAL to core:os 2024-08-05 12:49:12 -04:00
Feoramund eba0774bf3 Prevent SIGPIPE on Darwin when writing to a closed core:net socket
Mimics behavior found on Linux implementation.
2024-08-05 12:23:09 -04:00
gingerBill 7c3461b0df Merge pull request #4028 from Kelimion/fix-4026
Fix crash if referencing import "aliased" in other file.
2024-08-05 16:57:58 +01:00
Jeroen van Rijn 2cc3795686 Merge pull request #4027 from karl-zylinski/blend-pixel-compile-fix
Fix for blend_pixel.odin in core/image/common.odin not compiling
2024-08-05 17:38:30 +02:00
Karl Zylinski b63657d293 Fix for blend_pixel.odin in core/image/common.odin not compiling 2024-08-05 17:23:58 +02:00
Jeroen van Rijn 6175efde3d Fix crash if referencing import "aliased" in other file.
Fixes #4026
2024-08-05 17:23:50 +02:00
Jeroen van Rijn 030220eb22 Merge pull request #4025 from karl-zylinski/patch-2
core/image/common.odin compile fix
2024-08-05 16:42:09 +02:00
Karl Zylinski 2d32b819dc common.odin compile fix
Fix for "Error: Prefer to separate 'where' clauses with a comma rather than '&&'"
2024-08-05 16:32:34 +02:00
gingerBill f56abf3780 Add intrinsics.masked_expand_load and intrinsics.masked_compress_store 2024-08-05 14:54:09 +01:00
gingerBill 78919f8524 Fix typos 2024-08-05 14:48:55 +01:00
gingerBill 80ea4e0aeb Remove dead code 2024-08-05 14:25:33 +01:00
gingerBill 84ac56f778 Add intrinsics.simd_masked_load and intrinsics.simd_masked_store 2024-08-05 14:08:41 +01:00
gingerBill 7e701d1677 Add intrinsics.simd_gather and `intrinsics.simd_scatter 2024-08-05 13:46:24 +01:00
gingerBill b67ed78afd add_sat -> saturating_add 2024-08-05 13:21:27 +01:00
gingerBill 90fc52c2ee Rename add_sat -> saturating_add 2024-08-05 13:19:01 +01:00
gingerBill 9a01a13914 Add simd_reduce_any and simd_reduce_all 2024-08-05 13:13:19 +01:00
gingerBill eeb92e2644 Allow cast between #simd[N]rawptr <-> #simd[N]uintptr 2024-08-05 13:06:55 +01:00
gingerBill fd06be2243 Allow swizzle to take more arguments than the original array length 2024-08-05 12:33:02 +01:00
gingerBill a06cb8ba46 Add #simd[N]rawptr support 2024-08-05 12:04:36 +01:00
Feoramund d0d4f19097 Remove debug line from test 2024-08-05 03:50:41 -04:00
Feoramund 8f5b838a07 Review manual for loops in core:text/regex 2024-08-05 03:49:29 -04:00
Feoramund ba0581ae79 Give FreeBSD access to core:net in core:flags 2024-08-05 03:05:50 -04:00
Feoramund d9404d928c Add copyright info to core:sys/freebsd 2024-08-05 03:05:50 -04:00
Feoramund fe754af13d Add new contribution notes to core:net 2024-08-05 03:05:49 -04:00
Feoramund 61e770d943 Clean up some FreeBSD core:net code 2024-08-05 03:05:43 -04:00
Feoramund 2b63684ccf Fix integer socket option values for FreeBSD 2024-08-05 02:14:41 -04:00
Feoramund 5ece6980eb Make EINVAL generic in FreeBSD Socket_Option_Error
The documentation for `setsockopt(2)` mentioned accept filters for
`EINVAL`, but I've found that it can arise for any manner of invalid
values for setting socket options.

We'll just have to leave this as a generic error.
2024-08-05 02:14:27 -04:00
Feoramund 42a2297d31 Add core:net tests specifically for FreeBSD 2024-08-05 02:08:48 -04:00
Feoramund 8de48d81ea Use common name for ENOBUFS 2024-08-05 00:30:39 -04:00
Feoramund 32fb1fb61c Add missing ECONNRESET TCP_Send_Error
This was not specifically documented in `send(2)`.
2024-08-05 00:30:39 -04:00
Feoramund 05c50561ae Set NOSIGPIPE on all core:net FreeBSD sockets 2024-08-05 00:30:39 -04:00
Feoramund 46455dd0a6 Add more socket options for FreeBSD core:net 2024-08-05 00:30:24 -04:00
Feoramund 3f9ddfe029 Clarify what umtx is 2024-08-04 22:24:55 -04:00
Feoramund 14858309f0 Add explicit license info to core:text/regex 2024-08-04 19:18:16 -04:00
Feoramund e17fc8272b Document rationale behind RegEx shorthand classes 2024-08-04 19:12:46 -04:00
Feoramund dde42f0ebc Add more documentation for core:text/regex API 2024-08-04 18:56:29 -04:00
Feoramund ca7e46d56f Add explicit test case for Capture pos 2024-08-04 18:56:29 -04:00
Feoramund 743480b1a4 Use regex.destroy for test captures 2024-08-04 18:56:29 -04:00
Feoramund 1ccb0b2558 Remove unused code 2024-08-04 18:56:29 -04:00
Feoramund babdc432e9 Move Flag_To_Letter to core:text/regex/common 2024-08-04 18:56:25 -04:00
ed 975f7ba295 Merge remote-tracking branch 'offical/master'
# Conflicts:
#	core/os/os_darwin.odin
#	core/os/os_freebsd.odin
#	core/os/os_js.odin
#	core/os/os_linux.odin
#	core/os/os_openbsd.odin
#	core/os/os_windows.odin
2024-08-04 18:49:08 -04:00
Feoramund d3a51e208d Hide Regular_Expression values
We don't directly support printing these.

To prevent future issues being raised about the pattern being missing if
someone tries to print one, hide everything.
2024-08-04 18:40:27 -04:00
Feoramund cd8272557f Test that a RegEx Capture pos corresponds to its groups 2024-08-04 18:33:36 -04:00
gingerBill 7e0fa795e4 Just compare against nil directly if the comparator is known to be nil too 2024-08-04 21:17:58 +01:00
Feoramund 6252712363 Add missing features to regex package documentation 2024-08-04 13:21:13 -04:00
gingerBill 60bc7f53d2 Comment out open_buffered 2024-08-04 17:41:48 +01:00
gingerBill cf3c1a85ec Remove temp parameter 2024-08-04 17:36:28 +01:00
gingerBill 046f72befd Mock out open_buffered 2024-08-04 17:31:39 +01:00
gingerBill f19436fb4d Only swap if there was an arena 2024-08-04 17:17:09 +01:00
gingerBill d0709a7de2 Allow for nested temp_allocator() calls to flip between arenas on TEMP_ALLOCATOR_GUARDs 2024-08-04 17:14:24 +01:00
gingerBill f427f040fd Merge pull request #4020 from odin-lang/bill/os-errno
`os.Error` to replace `os.Errno`
2024-08-04 15:53:18 +01:00
gingerBill c078b2dd1b Add @(require_results) 2024-08-04 15:24:26 +01:00
gingerBill bf948ab8ae Add stubs for flush on platforms that didn't have it 2024-08-04 15:07:24 +01:00
gingerBill acb1ebddf6 Fix err != 0 uses 2024-08-04 15:01:04 +01:00
gingerBill 0bedd3357a Disallow err != 0 with os.Error when -strict-style is enabled 2024-08-04 14:58:12 +01:00
gingerBill 93fabf8628 Replace err != 0 with err != nil where possible 2024-08-04 14:57:25 +01:00
gingerBill fc10b781af Update core/os/os2/process.odin
Co-authored-by: Laytan <laytanlaats@hotmail.com>
2024-08-04 14:47:44 +01:00
gingerBill 6a6b5061db Update core/os/os_darwin.odin
Co-authored-by: Laytan <laytanlaats@hotmail.com>
2024-08-04 14:47:35 +01:00
gingerBill b67817517e Fix replace typo 2024-08-04 14:46:32 +01:00
gingerBill fff1d509d5 Add read_entire_file_or_err and write_entire_file_or_err 2024-08-04 14:41:55 +01:00
gingerBill e8d26c5797 Move errors to where appropriate 2024-08-04 13:41:34 +01:00
gingerBill 3d992e2704 Improve _error_string for Linux 2024-08-04 13:25:35 +01:00
gingerBill 0c5b645dde Correct EOF value 2024-08-04 13:20:33 +01:00
gingerBill cf5ec25873 Add extra cases for flush 2024-08-04 13:18:51 +01:00
gingerBill 7663a2036a Add read_at/write_at to missing platforms 2024-08-04 13:16:37 +01:00
gingerBill c32f345c68 Move error stuff to errors.odin 2024-08-04 12:55:08 +01:00
gingerBill 649b25fba6 Update the demo.odin to use nil instead of os.ERROR_NONE 2024-08-04 12:47:49 +01:00
gingerBill bdbbbf5c95 Fix typo; remove unneeded casts 2024-08-04 12:39:21 +01:00
gingerBill e8b6d15db9 Fix replace typo 2024-08-04 12:31:22 +01:00
gingerBill 5f7fef92fa Update example to use err != nil instead 2024-08-04 12:25:50 +01:00
gingerBill 66b86bc7e0 Correct os errors for darwin 2024-08-04 12:23:18 +01:00
gingerBill 5187bb68bb Hack: Convert 0 to nil 2024-08-04 12:08:52 +01:00
gingerBill 97c499dbb4 Begin mapping os.Error in the rest of the codebase 2024-08-04 11:58:04 +01:00
gingerBill 1d75a612d5 os.Errno -> os.Error 2024-08-04 11:47:23 +01:00
gingerBill 160048eaee Errno -> Error 2024-08-04 11:46:42 +01:00
gingerBill def2e2e271 Try to map to General_Error where possible 2024-08-04 11:44:45 +01:00
gingerBill 28666414bc More clean ups of ERROR_NONE and != nil usage 2024-08-04 11:37:49 +01:00
gingerBill a241168142 Clean up err != nil usage 2024-08-04 11:26:35 +01:00
gingerBill 29b6eebcd5 Clean up error handling 2024-08-04 11:21:09 +01:00
gingerBill 7dae38ce89 Begin mocking out for other errors 2024-08-04 11:12:45 +01:00
gingerBill 1826b0c700 Fix copy-replace errors 2024-08-04 11:10:17 +01:00
gingerBill 9f9abb8fb3 Use union #shared_nil for os.Error 2024-08-04 11:05:30 +01:00
gingerBill e60951a902 Begin converting os.Errno to be a nil-able type as a transition period 2024-08-04 10:51:08 +01:00
gingerBill 71932628cc Add alias 2024-08-04 10:08:48 +01:00
jason c691c7dc68 point stdin, stdout, stderr to /dev/null if unused in os2.process_start 2024-08-04 01:47:10 -04:00
jason 2a7db08c20 Remove returned bool from access and faccessat in sys/linux.
Switch to using AT_EMPTY_PATH to execve with file descriptors.
2024-08-04 00:59:40 -04:00
jason 2b89829b52 minor edits in process_linux.odin 2024-08-03 18:08:00 -04:00
Laytan Laats e77977c8ef fix vet errors in stb truetype 2024-08-03 23:56:19 +02:00
jason 38b96a7981 change child error behavior to trap instead of exit 2024-08-03 17:50:47 -04:00
Laytan Laats 4dd846fa29 fix readir_r link name for netbsd 2024-08-03 15:54:29 +02:00
Laytan Laats 61008232e4 actually fail CI when NetBSD tests fail 2024-08-03 15:43:35 +02:00
Jeroen van Rijn 90e573c54a Add image.premultiply_alpha helper. 2024-08-03 12:58:43 +02:00
Laytan ac483f72eb Merge pull request #4013 from laytan/fix-os-read-dir-with-symlinks
fix os.read_dir with symlinks
2024-08-03 01:08:23 +02:00
Laytan Laats 99d9e8f8b1 fix os.read_dir with symlinks 2024-08-03 00:26:46 +02:00
skytrias 9f5854e24e Update orca bindings and macros to requested changes 2024-08-02 23:46:02 +02:00
Laytan 772dce7e42 Merge pull request #3969 from elvodqa/master
Add `sdl2glue` to `vendor:wgpu` package
2024-08-02 17:18:34 +02:00
Emir e55d09bdfa Update vendor/wgpu/examples/sdl2/main.odin
Co-authored-by: Laytan <laytanlaats@hotmail.com>
2024-08-02 18:04:36 +03:00
Jeroen van Rijn 1a16585b10 Add image.pixels_to_image helper. 2024-08-02 14:54:52 +02:00
Laytan 500c117312 Merge pull request #4008 from Daxode/wasm-quality-of-life
Quality of Life changes to wgpu/js
2024-08-02 13:51:47 +02:00
daniel-andersen 723e6d19be right number whoops! 2024-08-02 13:38:36 +02:00
Jeroen van Rijn 8e8660fdfc Merge pull request #4007 from marcosantos98/fix-wasm
Fix: compilation error when using BufferSubDataSlice in webgl package
2024-08-02 12:31:23 +02:00
marcosantos98 3bfccde6f9 Fix: remove extra usage in webgl.odin:250
Compilation error when using webgl.BufferSubDataSlice.
The `usage` parameter is nowhere to be found.
This is probably a copy-pasta leftover.
2024-08-02 10:50:16 +01:00
daniel-andersen e7041f785a Quality of life changes to wgpu/wasm stuff 2024-08-02 11:04:10 +02:00
gingerBill 83599957b1 Merge pull request #3998 from zen3ger/os2-temp_file_linux
[os2] Add missing temp_file implementation for Linux
2024-08-01 20:07:21 +01:00
skytrias f8e0cda113 Add autogenerated orca bindings and macros from laytan 2024-08-01 19:19:24 +02:00
Jeroen van Rijn 0fa62937d5 Fix NetBSD CI 2024-07-31 20:19:13 +02:00
Jeroen van Rijn f627a38b4f Update rand.reset() example. 2024-07-31 20:00:55 +02:00
Jeroen van Rijn cc8c2f236b Merge pull request #4002 from thetarnav/update-builtin-constants
Update comments for builtin constants
2024-07-31 19:47:01 +02:00
Damian Tarnawski 953ae32607 Update builtin constants 2024-07-31 18:55:04 +02:00
Jeroen van Rijn fdfe6b00e0 Improve output path checking
Fixes #4001
2024-07-31 15:16:09 +02:00
Laytan 8a9901aeab Merge pull request #4000 from lxmcf/master
[vendor:raylib] Remove GuiStyleProp
2024-07-31 12:34:00 +02:00
Alex Macafee 1f2ab84e82 Use GuiControlProperty instead of c.int 2024-07-31 19:08:08 +10:00
Alex Macafee 92831d7ca3 Remove GuiStyleProp 2024-07-31 18:58:43 +10:00
Alex Macafee f33b4ecd3e Update Raygui Style set/get functions 2024-07-31 18:48:16 +10:00
gingerBill 62191f54a0 Merge pull request #3997 from Hyrtwol/reource-fix-windows
fix for using .rc files
2024-07-30 21:26:07 +01:00
gingerBill 04c3723985 Merge pull request #3992 from thetarnav/parser-patch
Correct the Array_Type.len comment and assign tok when making Ellipsis node
2024-07-30 21:25:21 +01:00
gingerBill ac19bb3a8c Merge pull request #3985 from flysand7/docs-sync
[sync]: Document all procedures
2024-07-30 21:24:59 +01:00
Roland Kovacs 1913c08b7b [os2] Add missing temp_file implementation for Linux 2024-07-30 18:11:44 +02:00
Thomas la Cour 744d7f7ef4 fix for using .rc files 2024-07-30 16:53:14 +02:00
jason c7eb2ae6bb use sys/linux dirent instead of manual iteration 2024-07-30 10:19:09 -04:00
jason 792640df1f remove File_Impl_Kind from file_linux 2024-07-30 09:41:49 -04:00
jason 278a63caaa remove pidfd availability caching 2024-07-30 09:28:40 -04:00
jason a03dffcd1a improve error handling; do not report errors from failed execve 2024-07-30 08:45:53 -04:00
flysand7 3aac4b1a3e [sync]: Document all procedures 2024-07-30 19:13:35 +11:00
Damian Tarnawski 478b2d7444 Correct the Array_Type.len comment and assign tok when making Ellipsis node 2024-07-29 22:14:42 +02:00
Laytan 7f17d4eb7f Merge pull request #3991 from laytan/fix-in-map-with-union-variants
fix `specific_union_variant in map_keyed_by_union` not converting to union type
2024-07-29 02:39:47 +02:00
Laytan Laats 4d1d754cae fix specific_union_variant in map_keyed_by_union not converting to union type 2024-07-29 02:32:13 +02:00
Jeroen van Rijn 24e6f16f4a Clamp dot in angle_between to avoid precision errors.
Fixes #3978
2024-07-28 15:00:29 +02:00
Laytan f852aac0e7 Merge pull request #3989 from colrdavidson/spall_doc
Improve Spall Docs slightly to reduce onboarding friction
2024-07-28 12:46:04 +02:00
Colin Davidson 27f75c40ab make example compile 2024-07-28 01:29:33 -07:00
Colin Davidson 1d598f8287 tweak doc a little to reduce onboarding friction for thread-users 2024-07-28 01:23:47 -07:00
Jeroen van Rijn cb31df34c1 Merge pull request #3362 from Hyrtwol/sys-windows-2
core/sys/windows part 2
2024-07-26 14:29:56 +02:00
Thomas la Cour 271ec643ed removed some comments 2024-07-26 11:30:48 +02:00
Thomas la Cour fe587ee79a try to add sys/windows to the normal core tests 2024-07-26 11:04:13 +02:00
Thomas la Cour b149b3d6c6 Merge remote-tracking branch 'upstream/master' into sys-windows-2 2024-07-26 10:45:09 +02:00
Thomas la Cour 03f3ea5a9e removed old test stuff 2024-07-26 10:43:26 +02:00
Thomas la Cour 6e6f2a1f6b removed obsolete fiels on WIN32_FIND_DATAW to match the size from the winsdk headers 2024-07-26 10:14:13 +02:00
Thomas la Cour 58ab6e5f94 missign cursorinfo 2024-07-26 10:07:20 +02:00
Jeroen van Rijn 4e194d5dbd Merge pull request #3980 from Kelimion/format-time
Add `time.to_string*` formatters.
2024-07-25 21:09:51 +02:00
Jeroen van Rijn 00c6b83537 Use constants in example. 2024-07-25 21:02:38 +02:00
Jeroen van Rijn ca7d86084e Improve docs. 2024-07-25 20:58:47 +02:00
Jeroen van Rijn 9088a493d9 Add time.to_string* formatters. 2024-07-25 19:43:42 +02:00
Thomas la Cour fe4754a77c format 2024-07-25 10:27:49 +02:00
Thomas la Cour 9d67d12d22 Merge remote-tracking branch 'upstream/master' into sys-windows-2
# Conflicts:
#	core/sys/windows/shell32.odin
2024-07-25 10:05:41 +02:00
gingerBill 9e82ae10ac Merge branch 'master' of https://github.com/odin-lang/Odin 2024-07-24 21:55:55 +01:00
gingerBill 85880f9def Add more NtDll stuff 2024-07-24 21:55:51 +01:00
Jeroen van Rijn 4ff62994bf Add CLSCTX_ALL 2024-07-24 22:54:17 +02:00
Feoramund 90f1f7fbdf Use unaligned_store in regex too 2024-07-24 16:48:49 -04:00
gingerBill 9b624ef9e1 Merge branch 'master' of https://github.com/odin-lang/Odin 2024-07-24 21:45:40 +01:00
gingerBill f03c2b7783 General clean up of os2.read_directory for Windows 2024-07-24 21:45:35 +01:00
Feoramund ff492e615c Use unaligned_load for regex virtual machine
This should hopefully avoid any issues with loading operands greater
than 8 bits on alignment-sensitive platforms.
2024-07-24 16:27:20 -04:00
Feoramund 042f6de478 Remove printing facilities for Regular_Expression
The `original_pattern` introduced a tenuous dependency to the expression
value as a whole, and after some consideration, I decided that it would
be better for the developer to manage their own pattern strings.

In the event you need to print the text representation of a pattern,
it's usually better that you manage the memory of it as well.
2024-07-24 16:27:20 -04:00
Feoramund c52a8a5f86 Allow configuring of MAX_CAPTURE_GROUPS for n > 10 2024-07-24 16:27:08 -04:00
Feoramund 16b644ad79 Use slice.zero instead 2024-07-24 15:23:20 -04:00
Feoramund e8537a3134 Add test cases for unclosed classes and repetition
Simplified error checking while I was at it, too.
2024-07-24 15:21:41 -04:00
Feoramund e642be8550 Fix handling of unclosed regex classes and repetitions 2024-07-24 15:17:37 -04:00
Jeroen van Rijn 33d6677514 Merge pull request #3951 from Kelimion/lua_test
Add Lua example to `vendor:lua` as well as basic tests.
2024-07-24 17:50:49 +02:00
Jeroen van Rijn 8d6ff51922 Copy lua54.dll during CI test 2024-07-24 17:43:51 +02:00
jason a5fa93e06d remove ctprintf; use fmt.caprintf; fix pipe_linux that I broke. 2024-07-24 10:23:23 -04:00
jasonKercher 215b21811e Merge branch 'master' into os2-process-linux 2024-07-24 10:14:59 -04:00
jason 95a8a4e7f0 typo - inverted logic 2024-07-24 10:12:16 -04:00
jason ecdd3887b2 fix process_info assumptions 2024-07-24 10:09:50 -04:00
gingerBill 2dbccbde54 Improve win32 types 2024-07-24 14:53:48 +01:00
gingerBill 07b1819dc8 Improve os2.read_directory 2024-07-24 14:53:33 +01:00
gingerBill 9d8953538b Add missing attribute 2024-07-24 14:25:42 +01:00
gingerBill d4af7b86a7 Begin cleaning up os2.read_directory 2024-07-24 14:19:30 +01:00
gingerBill 38e983cac6 Remove dead code 2024-07-24 13:47:57 +01:00
gingerBill 2ddaae45f3 Better handling of allocators 2024-07-24 13:47:22 +01:00
jason 16bdc6d240 use more iterators; global "has pidfd open" state is now thread-safe 2024-07-24 08:43:22 -04:00
gingerBill 6d2487a692 Add some more Ntdll calls 2024-07-24 13:38:14 +01:00
gingerBill c407e423d9 Add inode to os2.Stat 2024-07-24 13:37:56 +01:00
gingerBill 0e91c8368c Add allocator parameters to fmt.caprint* 2024-07-24 09:01:41 +01:00
gingerBill f08a53015c Merge pull request #3972 from laytan/testing-json-report
testing: add json reporting
2024-07-24 08:35:37 +01:00
Emir c98bb7da39 Update README.md 2024-07-24 10:33:34 +03:00
Emir ba81a81ca8 Update os_sdl2.odin 2024-07-24 10:29:34 +03:00
Emir 57dc6c2e94 Update os_sdl2.odin 2024-07-24 10:27:22 +03:00
Emir 95412df129 Add newline to glue_darwin.odin 2024-07-24 10:27:00 +03:00
Emir 2a2bedc85c Fix indentation and add full example 2024-07-24 10:22:18 +03:00
Laytan Laats f6488383d7 fix instrumentation features on LLVM versions with typed pointers
Fixes #3970
2024-07-24 02:43:53 +02:00
jason 0455e4b60f remove unused constants; fix comment 2024-07-23 19:48:18 -04:00
Laytan Laats 545fbc54c7 testing: add json reporting 2024-07-24 01:33:22 +02:00
jason 82deaa59ad os2 linux: fix order of operations bug in _open; fix process_info routine 2024-07-23 17:50:30 -04:00
jason 3c7d1f35db os2 process implementation for linux 2024-07-23 16:50:00 -04:00
Emir f9ef951b22 Add sdl2glue/glue_linux.odin 2024-07-23 22:39:50 +03:00
Laytan Laats fc2e31fcd0 fix build comment in os_freestanding 2024-07-23 20:51:00 +02:00
Emir e8e51db9ff Update glue.odin 2024-07-23 20:42:26 +03:00
Emir a429603195 Remove unused variable from example 2024-07-23 20:39:09 +03:00
Emir 42833d0471 Merge branch 'odin-lang:master' into master 2024-07-23 20:38:04 +03:00
Emir f3f08a4b47 Add sdl2glue to vendor:wgpu package + triangle example 2024-07-23 20:37:26 +03:00
gingerBill efa8c92bab Implement init_long_path_support 2024-07-23 17:46:22 +01:00
gingerBill 65fec9134e Use SHFileOperationW for remove_all on Windows 2024-07-23 17:30:42 +01:00
gingerBill a28392852a Mock out os2.remove_all for Windows 2024-07-23 17:05:41 +01:00
gingerBill 8037ace873 Begin work on os2/dir.odin 2024-07-23 16:47:49 +01:00
gingerBill 182454a1c0 Minor clean ups 2024-07-23 16:09:15 +01:00
gingerBill 24f9e2bbeb Begin mocking out the linux stuff on os2 2024-07-23 16:06:14 +01:00
gingerBill 61b9a5dbb2 Merge branch 'master' of https://github.com/odin-lang/Odin 2024-07-23 15:57:23 +01:00
gingerBill 0403626acf Add utility calls to os2 2024-07-23 15:57:17 +01:00
Laytan 6fc3d32d4b Merge pull request #3967 from thetarnav/remove-space
Remove space in indentation
2024-07-23 13:58:50 +02:00
Damian Tarnawski eb4f850b7f Remove space in indentation 2024-07-23 13:48:03 +02:00
Jeroen van Rijn da80c51195 Merge pull request #3966 from KyleNBurke/sys-windows-add-type
Add `NCCALCSIZE_PARAMS` to `sys/windows`
2024-07-23 07:45:44 +02:00
Kyle Burke 9d99f98194 Remove semicolon 2024-07-23 00:22:19 -05:00
Kyle Burke c32e12c3f5 Add NCCALCSIZE_PARAMS to sys/windows 2024-07-23 00:09:50 -05:00
Laytan c5fb72340a Merge pull request #3963 from andreas-jonsson/andreas-jonsson-patch-1
Use pkgsrc llvm for NetBSD CI
2024-07-23 04:20:54 +02:00
gingerBill b0fe777ede Propagate rodata a bit more in lb_const_value 2024-07-23 03:01:09 +01:00
gingerBill bc5b41938e Fix #3964 2024-07-23 02:40:51 +01:00
gingerBill 527c0b3202 Change lib for lz4 2024-07-23 00:19:42 +01:00
gingerBill 6eb28aeafc Check to see if people are return a slice of a local fixed array from a procedure 2024-07-22 22:52:10 +01:00
gingerBill 12b971746c vendor:compress/lz4
Bindings to lz4 library
2024-07-22 22:42:29 +01:00
gingerBill ef84382f23 Add suggestion for #3961 2024-07-22 20:11:23 +01:00
Feoramund b8f3d0fb53 Add core:text/regex to examples/all 2024-07-22 15:07:13 -04:00
Feoramund be38ba6c5e Add benchmarks for core:text/regex 2024-07-22 15:07:13 -04:00
Feoramund 3e49ceb82a Add tests for core:text/regex 2024-07-22 15:07:13 -04:00
Feoramund 730e10bd6f Support printing Regular_Expression in fmt 2024-07-22 14:25:12 -04:00
Feoramund cb0704d51c Add core:text/regex 2024-07-22 14:25:12 -04:00
Jeroen van Rijn 9cad8179b7 Clarify core:time Unix timestamp 2024-07-22 20:00:25 +02:00
Jeroen van Rijn ccf8b2764d Create README.md 2024-07-22 18:00:57 +02:00
gingerBill 915c5c3a87 Merge branch 'master' of https://github.com/odin-lang/Odin 2024-07-22 16:29:35 +01:00
gingerBill fcaa47986a Improve error handling for invalid syntax doing [*]T 2024-07-22 16:29:29 +01:00
Jeroen van Rijn 07d2aba310 Simplify exe path check. 2024-07-22 16:36:21 +02:00
Jeroen van Rijn 4889641af4 Merge pull request #3959 from Kelimion/fix-output-is-directory-check
Fix .exe path is directory check.
2024-07-22 16:22:17 +02:00
Jeroen van Rijn 90a4d12b30 Fix .exe path is directory check. 2024-07-22 16:11:33 +02:00
Jeroen van Rijn a39b6de18c Merge pull request #3958 from Kelimion/fix-3473
Fix #3473
2024-07-22 15:41:39 +02:00
Jeroen van Rijn 39657e4d96 Fix #3473
Fix the problem where the initial package's directory name ended in .odin.
2024-07-22 15:15:51 +02:00
Laytan 73a9a97413 Merge pull request #3476 from PucklaJ/syscall-fix
[sys/linux] Fix fork and execve syscalls on arm64
2024-07-22 13:58:17 +02:00
PucklaJ 1873f7215d [sys/linux]: Change execveat flags type to Execveat_Flags 2024-07-22 11:03:25 +02:00
Laytan Laats 4d86012d96 install lua for new lua vendor tests 2024-07-22 01:13:50 +02:00
Laytan Laats a055c03de9 use #directory in lua test 2024-07-22 01:11:01 +02:00
Laytan 68550cf915 Merge pull request #3957 from laytan/fix-any_base-and-any_core
fix `reflect.any_base` and `reflect.any_core` with any's containing nil
2024-07-22 01:09:38 +02:00
Laytan Laats 3e618bed40 fix reflect.any_base and reflect.any_core with any's containing nil 2024-07-22 00:51:38 +02:00
Jeroen van Rijn 51733fce68 Merge pull request #3952 from Ronaldr1985/master
Ensure that values in ini map are unquoted
2024-07-21 14:58:15 +02:00
Jeroen van Rijn a056e9da81 Merge pull request #3954 from flysand7/docs-thread
[thread]: Document all functions in core:thread
2024-07-21 14:10:49 +02:00
flysand7 b84b4c47d7 [thread]: Document all functions in core:thread 2024-07-21 14:34:36 +11:00
Jeroen van Rijn 431227d4c5 Add NULL check in check_range_stmt
Fixes #3953
2024-07-21 02:52:53 +02:00
Ronald 1a6885c2a3 Tidy up code 2024-07-21 00:08:20 +01:00
Ronald c3a57853e2 Ensure that values in ini map are unquoted 2024-07-21 00:00:47 +01:00
Jeroen van Rijn fc5ce30f34 Allow json to unmarshal empty struct. 2024-07-21 00:37:11 +02:00
Jeroen van Rijn 572b400d8e Merge pull request #3950 from Ronaldr1985/master
Add tests for encoding/ini
2024-07-20 18:47:08 +02:00
Jeroen van Rijn f78a792d48 Add Lua example to vendor\lua as well as basic tests. 2024-07-20 18:30:41 +02:00
Ronald e0a8bd04d5 Ensure deletion of maybe is delayed until we're finished with it. 2024-07-20 17:10:34 +01:00
Ronald f560b14d10 Fix typo in name of test 2024-07-20 17:10:19 +01:00
Ronald b584eeaade Add encoding/ini tests 2024-07-20 16:53:54 +01:00
Jeroen van Rijn cdd2c98b8d Merge pull request #3948 from flysand7/docs-time
[time]: Document all functions
2024-07-20 16:06:07 +02:00
Jeroen van Rijn 9d6ed991cb Remove LUA panic for non-big-3 OS 2024-07-20 14:33:34 +02:00
Jeroen van Rijn 2385e1ddd9 Update LUA imports for Darwin. 2024-07-20 14:24:01 +02:00
flysand7 b3ca2d5e0a [time]: Document all functions 2024-07-20 18:48:50 +11:00
Jeroen van Rijn 64614889de Merge pull request #3946 from flysand7/x11-fixes
[vendor/x11]: Fix missing argument in XDefaultDepth, wrong types in CreateSimpleWindow
2024-07-20 04:00:00 +02:00
Jeroen van Rijn d9d044970e Merge pull request #3945 from flysand7/docs-datetime
[time/datetime]: Document package datetime
2024-07-20 03:56:21 +02:00
flysand7 0c78cab336 [time/datetime]: Document package datetime 2024-07-20 12:49:40 +11:00
flysand7 15997d2a90 [vendor/x11]: Fix missing argument in XDefaultDepth, wrong types in CreateSimpleWindow 2024-07-20 12:47:00 +11:00
Jeroen van Rijn 7237f9c9f8 Help text default -o:none -> -o:minimal. 2024-07-19 20:47:26 +02:00
gingerBill ba3d7ba5d3 Add core:encoding/ini to examples/all 2024-07-19 12:03:34 +01:00
gingerBill f226eba342 Merge branch 'master' of https://github.com/odin-lang/Odin 2024-07-19 12:00:54 +01:00
gingerBill 393ca40c23 Minor clean ups 2024-07-19 12:00:49 +01:00
gingerBill 62f455f47b Merge branch 'master' into syscall-fix 2024-07-19 11:43:56 +01:00
gingerBill 163287d9ce Merge pull request #3938 from Ronaldr1985/master
Fix memory leak in encoding/ini
2024-07-19 11:42:35 +01:00
gingerBill 2f8399fe20 Merge pull request #3940 from flysand7/os2-handle-inheritance
[os2] Make all handles non-inheritable by default
2024-07-19 11:38:03 +01:00
gingerBill 685dbddcb5 Merge pull request #3939 from flysand7/os2-file-type
[os2]: Split file type from mode bits et other small fixes
2024-07-19 11:37:54 +01:00
Laytan Laats 27f9f0ba17 fix OLS #431, #393 2024-07-18 21:06:37 +02:00
Laytan Laats 2b6a926bb6 fix OLS #52 2024-07-18 21:06:37 +02:00
Laytan b3d798cb76 Merge pull request #3941 from laytan/wgpu-wayland-improvements
improve WGPU / GLFW / Wayland story by weak linking and adjusting docs
2024-07-18 20:20:01 +02:00
Laytan 7134015f56 improve WGPU / GLFW / Wayland story by weak linking and adjusting docs 2024-07-18 19:28:15 +02:00
flysand7 7b501b22bb [os2]: Split file type from mode bits 2024-07-18 23:09:27 +11:00
flysand7 75605a47e7 [os2]: Make anonymous pipes always inheritable 2024-07-18 22:57:30 +11:00
flysand7 4dcb75af6d Make all handles non-inheritable by default
The sockets are left as non-inheritable because they
never should be inherited.
2024-07-18 22:50:47 +11:00
Ronald c768d0719a Remove unnecessary change
This was accidentally added, it was a change I made whilst testing.
2024-07-17 21:57:35 +01:00
Ronald f04db7145c Fix memory leak in encoding/ini
A simple change that fixes a memory leak caused by not deleting all the
values in the map
2024-07-17 21:19:14 +01:00
gingerBill 0bb4cc6ce5 Merge pull request #3935 from IllusionMan1212/win32-drag-n-drop
core/sys/windows: added drag and drop procedures
2024-07-16 23:41:52 +01:00
IllusionMan1212 07121f81ff core/sys/windows: added drag and drop procedures 2024-07-17 00:32:25 +02:00
Jeroen van Rijn 5520b45457 Add glfw LICENSE file 2024-07-16 22:59:32 +02:00
Laytan cb16d2ddaf Merge pull request #3934 from laytan/fix-saturating-intrinsics
fix `add_sat` and `sub_sat` intrinsics
2024-07-16 22:30:06 +02:00
Laytan Laats a6d1a2e46c add #optional_ok to docs file for intrinsics 2024-07-16 22:22:06 +02:00
Laytan Laats 47f14dd9ea type is never a tuple here 2024-07-16 22:11:54 +02:00
Laytan Laats 853487e86c fix add_sat and sub_sat intrinsics 2024-07-16 22:07:49 +02:00
gingerBill 0d881e1561 Improve rand.shuffle further by splitting into 64-bit and 32-bit parts 2024-07-16 18:36:31 +01:00
gingerBill ba49950454 Improve rand.shuffle 2024-07-16 18:33:01 +01:00
gingerBill f66133959f Merge pull request #3933 from laytan/fix-some-bugs-with-disable-assert
fix some bugs with -disable-assert
2024-07-16 17:54:21 +01:00
Laytan Laats 28fac62a02 fix some bugs with -disable-assert 2024-07-16 18:44:18 +02:00
gingerBill a3fe5754d9 Make complex32 use higher precision where possible for calculations 2024-07-16 15:31:00 +01:00
gingerBill df56655ab1 Fix formatting inconsistencies 2024-07-16 14:03:02 +01:00
gingerBill 6702f07762 rawptr -> cstring 2024-07-16 14:02:07 +01:00
gingerBill 03e90bf924 Use RTTI to get the error_string for Windows 2024-07-16 12:26:24 +01:00
gingerBill 8d70a264ab Check for specific error directly 2024-07-16 12:21:55 +01:00
gingerBill fe718460c6 Clean up bit_set usage 2024-07-16 12:17:48 +01:00
gingerBill 1afb10109e Remove the need for temporary variables where possible 2024-07-16 12:13:39 +01:00
gingerBill 3a162de18f More clean up for process_windows.odin 2024-07-16 12:08:59 +01:00
gingerBill 321ef82d76 Add @(require_results) where needed 2024-07-16 11:57:22 +01:00
gingerBill 169fc4d3be General clean up of the os2/process_windows.odin code 2024-07-16 11:56:31 +01:00
gingerBill affe8f7144 Merge pull request #3310 from flysand7/core-process
Addition of `core:os2/process` api.
2024-07-16 11:24:24 +01:00
gingerBill 23ca27f40b Add intrinsics add_sat and sub_sat 2024-07-16 00:48:17 +01:00
Laytan Laats 03426175ae add workaround for kernel panics on MacOS 2024-07-15 22:45:16 +02:00
Jeroen van Rijn 0a9c150748 Merge pull request #3929 from laytan/fix-fmt-len-transfer-to-children
fmt: fix optional_len or use_nul_termination being used by both array and elems
2024-07-15 19:36:20 +02:00
Laytan Laats f362e0fa20 add test for leaking struct tag into elems 2024-07-15 19:27:48 +02:00
Laytan Laats d4d910bcfc fmt: fix optional_len or use_nul_termination being used by both array and elems
```odin
My_Struct :: struct {
	names:      [^]string `fmt:"v,name_count"`,
	name_count: int,
}

main :: proc() {
	name := "hello?"
	foo := My_Struct {
		names = &name,
		name_count = 1,
	}
	fmt.println(foo)
}
```

Before: `My_Struct{names = ["h"], name_count = 1}`
After:  `My_Struct{names = ["hello?"], name_count = 1}`
2024-07-15 18:51:18 +02:00
Jeroen van Rijn 3a75a8dd1b Merge pull request #3928 from Yawning/feature/aes-ni
core/crypto: Support AES-NI + PCLMUL
2024-07-15 18:41:21 +02:00
Yawning Angel 33dae2e26c core/crypto/aes: Support the full range of GCM nonce sizes 2024-07-16 01:29:43 +09:00
Yawning Angel 69026852ce core/crypto/aes: Add Intel AES-NI support
This supports AES-NI + PCLMUL, and provides optimized key schedule, ECB,
CTR, and GCM.  Other modes are trivial to add later if required.
2024-07-16 01:29:43 +09:00
Yawning Angel f578994fa6 core/simd/x86: Make the AES-NI intrinsics consistent with Intel 2024-07-16 01:29:43 +09:00
Yawning Angel 1bc21c3481 core/crypto/_aes: Remove redundant sanity checks 2024-07-16 01:29:43 +09:00
Yawning Angel c9c0b9ea7b core/crypto: Fix/add some documentation (NFC) 2024-07-16 01:29:43 +09:00
Yawning Angel 390cd3c30d core/simd/x86: Fix some intrinsics
- _mm_slli_si128 produced totally incorrect output
- _mm_storeu_si128 refered to a LLVM intrinsic that is missing
2024-07-16 01:29:43 +09:00
Yawning Angel 401877184f tests/benchmark/crypto: Benchmark AES256-CTR 2024-07-16 01:29:43 +09:00
Yawning Angel 4815154c31 test/core/crypto: Fix a copy-paste issue in failure spew 2024-07-16 01:29:43 +09:00
Yawning Angel 0d8dadec8a tests/core/crypto: Fix new -vet issues 2024-07-16 01:29:43 +09:00
Yawning Angel ff13ee3281 core/crypto: Enforce aliasing restrictions 2024-07-16 01:29:43 +09:00
Yawning Angel dcaf085bfa core/bytes: Add alias and alias_inexactly 2024-07-16 01:29:43 +09:00
Laytan Laats 55e0f97cc4 help fmt with Type_Info_Struct and Type_Info_Bit_Field changes 2024-07-15 18:29:06 +02:00
gingerBill 65c91b7dde Fix code gen issue with bit_set 2024-07-15 15:16:23 +01:00
gingerBill bd562116b8 Minor change to an internal flag 2024-07-15 15:08:26 +01:00
gingerBill 1e37eaf54d Begin work for bit_set[...; [N]T] (not working) 2024-07-15 14:49:20 +01:00
flysand7 8df61b7209 [os2/process]: Make get_args() private and use heap_allocator 2024-07-15 23:28:03 +11:00
Yawning Angel 1a30d47ee8 repo: Cleanup the .gitignore to match the new test runner 2024-07-15 21:25:07 +09:00
gingerBill 5cefab8229 Fix case: in type switch issue 2024-07-15 13:22:50 +01:00
gingerBill 7d643bcae3 Make linkage weak in certain places 2024-07-15 12:30:32 +01:00
gingerBill 549311fac9 Fix global variables being "missing" with -use-separate-modules 2024-07-15 12:21:42 +01:00
gingerBill c5decd3eae Fix possible race and correct linkage _after_ generation 2024-07-15 11:49:07 +01:00
flysand7 255f00d971 [os2/process]: Implement missing functionality, update docs 2024-07-15 20:24:05 +11:00
gingerBill 664a71454b -use-separate-modules default on Windows only 2024-07-15 02:53:01 +01:00
gingerBill 432388ac7f Generate backing array in the case where there is no DeclInfo for the procedure body 2024-07-15 02:42:28 +01:00
gingerBill cc3cf12ae2 Disable -use-separate-modules by default on darwin until problem is determined 2024-07-15 02:28:27 +01:00
gingerBill d87583bead Minimize mutex lock for #load_directory 2024-07-15 02:22:23 +01:00
gingerBill 1b0e98116d Revert changes to in_single_threaded_checker_stage 2024-07-15 01:47:52 +01:00
gingerBill eb6805ef40 Disable the need for mutexes in single threaded checker stage 2024-07-15 01:44:23 +01:00
gingerBill a45e05bb18 Remove need for BlockingMutex in Arena 2024-07-15 01:36:54 +01:00
gingerBill e4ba786948 Remove use of mutex in single threaded code 2024-07-15 01:29:57 +01:00
gingerBill cae8c1e94f Minimize use of mutex in Arena 2024-07-15 01:15:00 +01:00
gingerBill a8f84c87ae Add the permanent and temporary arenas directly on the Thread 2024-07-15 01:05:29 +01:00
gingerBill c64702ae5a Make -use-separate-modules the default behaviour for -o:none and -o:minimal 2024-07-15 00:43:46 +01:00
gingerBill 3311ea1c76 Keep MSVC happy with secure versions of C calls 2024-07-15 00:38:10 +01:00
gingerBill 018026d844 Use gb_zero_* calls 2024-07-15 00:36:00 +01:00
gingerBill 139c1bcdda Comment out debug code 2024-07-15 00:25:41 +01:00
gingerBill 46817e8f68 Merge branch 'master' of https://github.com/odin-lang/Odin 2024-07-15 00:01:31 +01:00
gingerBill 196ac7e6d6 Type erase _make_dynamic_array_len_cap 2024-07-15 00:01:26 +01:00
Jeroen van Rijn e3e31b42d0 #force_no_inline build_huffman to avoid bloat 2024-07-15 00:54:08 +02:00
gingerBill f7cb711874 Add #force_no_inline 2024-07-14 23:48:33 +01:00
gingerBill f657055f12 Add slice variable if not exists 2024-07-14 23:36:54 +01:00
gingerBill 26a9416a41 Minor clean ups 2024-07-14 23:33:35 +01:00
gingerBill e768bddaeb Inline _append_elem_string further 2024-07-14 23:22:22 +01:00
gingerBill 83b7dd122a Type erase for append_elems 2024-07-14 23:20:50 +01:00
gingerBill b0fbaf24a0 Type erase append_elem 2024-07-14 23:16:11 +01:00
gingerBill 1c3240b6b5 Add #force_no_inline 2024-07-14 23:09:58 +01:00
gingerBill 7673d478b6 Merge branch 'master' of https://github.com/odin-lang/Odin 2024-07-14 23:09:17 +01:00
gingerBill 15fb4ded2a type erase resize and reserve internals 2024-07-14 23:09:10 +01:00
Jeroen van Rijn 03cb585845 Merge pull request #3908 from NicknEma/Intrusive-list-docs
Write docs for `core:container/intrusive/list` package
2024-07-14 23:28:53 +02:00
gingerBill 9d84e00502 Clean up unquote code 2024-07-14 22:25:26 +01:00
gingerBill 7703b37a1b Merge branch 'master' of https://github.com/odin-lang/Odin 2024-07-14 22:23:52 +01:00
gingerBill 95a695e4cd Fix #3926 2024-07-14 22:23:46 +01:00
gingerBill 02408b713a Merge pull request #3910 from VladPavliuk/json-add-int-key-map-support
Allow to `marshal` and `unmarshal` maps with int keys
2024-07-14 22:00:01 +01:00
gingerBill 251fa477af Fix type 2024-07-14 21:39:33 +01:00
gingerBill 15a0655988 Merge branch 'master' of https://github.com/odin-lang/Odin 2024-07-14 21:37:41 +01:00
gingerBill 399c3ab067 Reduce the size of runtime.Type_Info 2024-07-14 21:37:35 +01:00
flysand7 b7ccfed9af [os2/process]: Implement process_kill 2024-07-15 07:27:44 +11:00
flysand7 4eca60946c [os2/process]: Refactor process_info procs, add process_info_by_handle 2024-07-15 07:27:44 +11:00
flysand7 8f4755532e [os2/process]: Adjust docs on process_close function 2024-07-15 07:27:44 +11:00
flysand7 63d94301fc [os2/process]: Implement process creation procedures 2024-07-15 07:27:43 +11:00
flysand7 e1eed7610c [os2/process]: Fix leaking memory on errors 2024-07-15 07:27:43 +11:00
flysand7 5d6e0bc793 [os2/process]: Implement retrieving command args in process info 2024-07-15 07:27:43 +11:00
flysand7 c1f5d8f006 [os2/process]: Improve documentation for *process_info() family of function 2024-07-15 07:27:43 +11:00
flysand7 f3d4a734d8 [os2/process]: Fix environment block null-terminator counting 2024-07-15 07:27:43 +11:00
flysand7 6387cd2c24 [os2/process] Added process_info() procedure 2024-07-15 07:27:43 +11:00
flysand7 56d55e4a86 Rebase master 2024-07-15 07:27:43 +11:00
flysand7 6fab055f43 [os2/process]: Add process list function 2024-07-15 07:27:43 +11:00
flysand7 2495f1c39a [os2/process]: Fill in basic functions 2024-07-15 07:27:43 +11:00
Jeroen van Rijn 65dab3a3b1 Merge pull request #3925 from Feoramund/fix-no-return-switch
Fix compiler crash when switching on no value
2024-07-14 21:26:46 +02:00
Feoramund b38237e8f0 Fix compiler crash when switching on no value 2024-07-14 14:59:00 -04:00
NicknEma 63276a85ba Fixed grammar and expanded info
Fixed points made by Jeroen.
2024-07-14 18:18:12 +02:00
VladPavliuk 3f8712edb0 Merge branch 'master' into json-add-int-key-map-support 2024-07-14 18:22:20 +03:00
gingerBill e7d37607ef Fix parameter to none 2024-07-14 16:05:47 +01:00
gingerBill 6feace2351 Add pseudo flag -fast-build 2024-07-14 16:05:07 +01:00
gingerBill a867378418 Default to -o:minimal again 2024-07-14 15:55:26 +01:00
gingerBill 11e2aa2d51 Improve error message 2024-07-14 15:31:40 +01:00
gingerBill 556355ef05 Disallow global use of target specific procedure calls 2024-07-14 15:30:40 +01:00
gingerBill 5de6016e7f Clean up os2.File.impl usage 2024-07-14 15:26:59 +01:00
gingerBill 2d56e3805b Merge branch 'master' of https://github.com/odin-lang/Odin 2024-07-14 15:09:38 +01:00
gingerBill 4f73b35da5 Make os2.File a more generic interface 2024-07-14 15:09:33 +01:00
Jeroen van Rijn 76b0562acd Merge pull request #3923 from laytan/fix-off-by-one-in-queue-back
Fix off-by-one in queue `back` and `back_ptr` procs
2024-07-14 16:09:16 +02:00
Laytan Laats d90d7ed002 Fix off-by-one in queue back and back_ptr procs 2024-07-14 16:00:55 +02:00
gingerBill 3d38f14202 Use fstat on os2.File directly 2024-07-14 14:51:22 +01:00
gingerBill d1450e3d88 Fix styling issues 2024-07-14 14:44:22 +01:00
gingerBill eff46c2e5f Merge pull request #3919 from colrdavidson/growing_workpool
move to a growing workstealing queue
2024-07-14 14:39:49 +01:00
gingerBill 8319917898 Merge branch 'master' of https://github.com/odin-lang/Odin 2024-07-14 14:07:42 +01:00
gingerBill 2e0c5fefde Reuse the slice value too for variadic parameters (LLVM >= 13) 2024-07-14 14:07:36 +01:00
Jeroen van Rijn 88823c4024 Merge pull request #3921 from Ronaldr1985/master
Fix logic bug in core/encoding/ini/ini.odin
2024-07-14 14:48:47 +02:00
gingerBill 6959554040 Calculate size and alignment, and reuse memory for all variadic calls within a procedure body 2024-07-14 13:44:47 +01:00
gingerBill 0a530b5ce8 Add error for #no_capture being reserved for future use 2024-07-14 13:20:12 +01:00
gingerBill 8650180ccc Change Odin calling convention to not do a copy on byval for SysV 2024-07-14 12:59:55 +01:00
gingerBill 5027c7081e Reuse slice variable for variadic parameters 2024-07-14 12:50:33 +01:00
gingerBill 3533094cc2 Restrict #no_capture to pointer-like types only 2024-07-14 12:44:13 +01:00
gingerBill 5ce6676914 Make #no_capture map to nocapture 2024-07-14 12:41:16 +01:00
gingerBill 3dff83f3dc Mock out #no_capture for future use 2024-07-14 12:39:30 +01:00
gingerBill 8642d719f0 Imply #no_capture to all variadic parameters 2024-07-14 12:19:47 +01:00
gingerBill 891cf54b5c Add f16 to #c_vararg promotion rules 2024-07-14 12:03:34 +01:00
gingerBill 3ba19d94cf Add #no_capture to core:odin/ast 2024-07-14 11:58:26 +01:00
gingerBill c7bd954752 Add more uses of #no_capture 2024-07-14 11:56:04 +01:00
Ronald 7e4e3429d7 Fix logic bug in core/encoding/ini/ini.odin
The load_map_from_path had incorrect logic where it would return false
for ok when err was equal to nil and true when there was an error.
2024-07-14 11:48:34 +01:00
gingerBill edc793d7c1 Add #no_capture args: ..T to reuse the backing array stack memory 2024-07-14 11:39:05 +01:00
gingerBill f98a7b84df Merge pull request #3914 from VladPavliuk/json-add-ignore-tag-support
Add support of `ignore` tag for `json.marshal`
2024-07-14 10:38:15 +01:00
gingerBill 0050cb9471 Merge pull request #3918 from flysand7/file-handle-inheritance2
[os2/file]: Fixes related to handle inheritance
2024-07-14 10:36:10 +01:00
Colin Davidson 64feb7599e move to isize 2024-07-14 00:33:40 -07:00
Colin Davidson 4420128dc1 handle steal-fail vs steal-empty 2024-07-14 00:29:58 -07:00
Colin Davidson cdede4928c move to a growing queue 2024-07-13 23:16:22 -07:00
flysand7 b686b072d5 [os2/file]: Fixes related to handle inheritance
All file handles created on Windows used to be made
non-inheritable, by forcing the .Close_On_Exec flag
in _open() function. In addition, there was an
issue with security descriptor being freed before
use, which has been fixed.
2024-07-14 15:06:28 +11:00
VladPavliuk 76fe5d1346 Align ignore syntax of json tags with fmt, cbor 2024-07-14 00:21:05 +03:00
gingerBill 8cebc7cc0c Merge pull request #3915 from tadeohepperle/vendor-wgpu-RenderPassEncoderSetPushConstants-signature
vendor/wgpu: RenderPassEncoderSetPushConstants should take a rawptr instead of cstring
2024-07-13 15:16:21 +01:00
Tadeo hepperle 75076e2d64 RenderPassEncoderSetPushConstants should take a rawptr instead of cstring for the data 2024-07-13 16:01:33 +02:00
VladPavliuk 64ae99f016 Add support of ignore tag for json.marshal 2024-07-13 14:13:59 +03:00
Jeroen van Rijn d845a07519 Merge pull request #3912 from xzores/master
Update stb_truetype.odin
2024-07-13 00:16:34 +02:00
xzores b4683f4399 Update stb_truetype.odin 2024-07-12 23:57:45 +02:00
VladPavliuk 79e2f63182 Small code refactoring in test_core_json 2024-07-13 00:38:58 +03:00
VladPavliuk 39983eaaa4 Remove unused imports in test_core_json 2024-07-13 00:26:54 +03:00
VladPavliuk dbdad0476d Allow to marshal and unmarshal maps with int keys 2024-07-13 00:07:48 +03:00
Thomas la Cour 3627a51daf Merge remote-tracking branch 'upstream/master' into sys-windows-2 2024-07-12 16:06:48 +02:00
gingerBill e715674512 Merge pull request #3907 from flysand7/console-read-fix
[core/os]: Fix read_console edge case bug
2024-07-12 14:58:40 +01:00
gingerBill 9e0c4098be Merge pull request #3905 from flysand7/winapi-process-procs
[sys/windows]: Advapi bindings, process-related functions and thread context
2024-07-12 14:58:27 +01:00
NicknEma d10694901f Simplify and fix doc examples
Remove unnecessary examples;
fix compilation errors in the remaining ones
2024-07-12 15:48:47 +02:00
NicknEma c75a872909 Write doc comments in intrusive_list.odin
Write description, inputs/returns and some examples for each procedure
2024-07-12 15:37:34 +02:00
NicknEma a348a7e84e Create doc.odin
Create a doc file with a brief of the package and an example program (copied from a discord message by laytan)
2024-07-12 15:18:58 +02:00
flysand7 a7d95ab3e1 [core/os]: Fix read_console not stopping the read when newline can't fit in output slice 2024-07-12 20:28:38 +11:00
flysand7 6ae47c6f43 [sys/windows] Add advapi bindings, process-related functions and context-related stuff 2024-07-12 19:21:44 +11:00
Thomas la Cour 3291c59728 post rebase 2024-07-11 21:37:37 +02:00
Thomas la Cour dd75b7a4d9 Merge remote-tracking branch 'upstream/master' into sys-windows-2
# Conflicts:
#	core/sys/windows/kernel32.odin
#	core/sys/windows/types.odin
#	core/sys/windows/user32.odin
#	core/sys/windows/winerror.odin
2024-07-11 21:20:53 +02:00
gingerBill 1770e3a9a9 Fix typo 2024-07-11 17:19:12 +01:00
gingerBill 19753ed8a3 Add rand.Generator and other calls 2024-07-11 17:12:42 +01:00
gingerBill 59d87d1f05 Add gen := context.random_generator parameters to rand calls 2024-07-11 17:01:34 +01:00
gingerBill 6b3453cc64 Fix #3902 2024-07-11 13:08:38 +01:00
gingerBill 5e7634d90c Merge branch 'master' of https://github.com/odin-lang/Odin 2024-07-11 13:04:32 +01:00
gingerBill fc7c7cd8ab Merge pull request #3900 from Kelimion/winres
Allow precompiled resources with `-resource:foo.res`
2024-07-11 12:51:25 +01:00
gingerBill e05e99253b Merge pull request #3904 from laytan/make-instrumentation-work-on-wasm
make instrumentation "work" on wasm
2024-07-11 12:50:51 +01:00
Jeroen van Rijn a8ce5bd005 Merge pull request #3903 from laytan/allow-mem-virtual-import-on-more-targets
allow `core:mem/virtual` import on more targets by expanding the `other` implementation
2024-07-11 02:12:53 +02:00
Laytan Laats 65ca03a930 make instrumentation "work" on wasm
Using instrumentation on WASM causes it to complain about the
llvm.returnaddress instrinsic. This PR could be considered a "hack" but
makes this work by just passing `nil` instead of the return address.
2024-07-11 01:57:00 +02:00
Laytan Laats 0dfc660c71 allow core:mem/virtual import on more targets by expanding the other implementation 2024-07-11 01:55:59 +02:00
Jeroen van Rijn c49afb0039 Add hinstdll forward to runtime globals 2024-07-10 19:58:29 +02:00
Jeroen van Rijn b02291b20a Compile demo with -vet -strict-style. 2024-07-10 19:26:35 +02:00
gingerBill f75a45c3fa Add aliases starts_with and ends_with 2024-07-10 16:34:15 +01:00
gingerBill 7e41340510 Unify IUnknown COM interface 2024-07-10 15:20:07 +01:00
Jeroen van Rijn 4148c6d6c7 #if WINDOWS 2024-07-10 15:25:49 +02:00
Jeroen van Rijn cc73e06a46 Allow precompiled resources with -resource:foo.res
And add them to the magic new feature.
2024-07-10 15:09:13 +02:00
gingerBill 733b7c704c Merge branch 'master' of https://github.com/odin-lang/Odin 2024-07-10 13:45:27 +01:00
gingerBill c54e3d3c4f Improve warning handling for possible default: typo 2024-07-10 13:45:21 +01:00
Jeroen van Rijn 8dc4eca4d2 Allow using precompiled .res file. 2024-07-10 14:25:18 +02:00
gingerBill 34c6868e78 Merge pull request #3895 from laytan/fix-optimization-mode-attribute
remove misleading @(optimization_mode) values and make "none" inhibit optimizations
2024-07-10 13:22:57 +01:00
gingerBill 38315f83da Merge pull request #3898 from laytan/fix-enable-target-features-for-poly-procs
fix require/enable target feature attribute on poly procs
2024-07-10 13:22:06 +01:00
gingerBill 5aa1f3751b Merge pull request #3899 from laytan/fix-more-attributes-not-applied-to-poly-procs
fix optimization mode, cold, and disabled not being applied to poly procs
2024-07-10 13:21:57 +01:00
gingerBill 36301d0359 Give better syntax error messages for things like #define Example 123 2024-07-10 13:03:38 +01:00
gingerBill c83307f26f Give error message suggestion when doing ^x instead of x^ if x is an r-value 2024-07-10 12:39:42 +01:00
gingerBill 30204837ce Merge branch 'master' of https://github.com/odin-lang/Odin 2024-07-10 12:28:23 +01:00
gingerBill f85f6b338a Change .. variadic logic; comment out unneeded error message 2024-07-10 12:28:15 +01:00
Laytan Laats 40625b24e2 fix optimization mode, cold, and disabled not being applied to poly procs 2024-07-09 19:49:12 +02:00
Laytan Laats 1fce5791a1 fix require/enable target feature attribute on poly procs 2024-07-09 19:33:25 +02:00
Jeroen van Rijn d43a2daa17 Merge pull request #3897 from Kelimion/simd-vet
Let simd/x86 pass new transmute/cast vet.
2024-07-09 17:04:45 +02:00
Jeroen van Rijn 7b31acd2d7 Let simd/x86 pass new transmute/cast vet. 2024-07-09 16:50:55 +02:00
gingerBill b83822fd35 #3892 - Use temporary directory for asm file generation 2024-07-09 15:41:05 +01:00
gingerBill ae2f16edea Fix #3894 2024-07-09 15:29:36 +01:00
gingerBill 9782d7b928 Merge pull request #3896 from odin-lang/cached-builds
Internal Cached Builds
2024-07-09 15:27:45 +01:00
gingerBill 5627af582a Add RPROMPT to blacklist 2024-07-09 15:18:15 +01:00
gingerBill d701642293 Check for PROMPT 2024-07-09 15:15:23 +01:00
gingerBill 4c1754b1dc environ is only for Linux 2024-07-09 14:56:12 +01:00
gingerBill 666703f430 Mock out \*nix stuff for cached.cpp 2024-07-09 14:47:22 +01:00
gingerBill 14dc3598b4 Add gb_internal to procedures 2024-07-09 14:33:01 +01:00
gingerBill 330d0e7a2a Add debugf calls 2024-07-09 14:30:38 +01:00
gingerBill 952fb998e6 Check for CURR_DATE_TIME 2024-07-09 14:20:55 +01:00
gingerBill 886ee66e7f Cache files, env, and args 2024-07-09 14:16:56 +01:00
gingerBill 68b70a2183 Check for bounds check error 2024-07-09 13:35:52 +01:00
gingerBill ccdad8b8dd Add odin clear-cache 2024-07-09 13:31:54 +01:00
gingerBill 45bf180847 Add subtarget to cached executable 2024-07-08 23:55:01 +01:00
gingerBill 87ac68fcf2 Add -internal-cached 2024-07-08 23:39:14 +01:00
Jeroen van Rijn 9575d85f1a Merge pull request #3511 from IllusionMan1212/x11-xkb
vendor/x11: some XKB extension procedures and constants
2024-07-08 21:14:26 +02:00
Laytan Laats 2d8d0dd851 fix @(optimization_mode) usage in builtin collections 2024-07-08 21:07:53 +02:00
Laytan Laats 1a20b78633 remove misleading @(optimization_mode) values and make "none" inhibit optimizations 2024-07-08 21:06:57 +02:00
IllusionMan1212 0c27d95679 vendor/x11: some XKB extension procedures and constants 2024-07-08 21:00:19 +02:00
gingerBill a3af94eeae Merge pull request #3893 from laytan/temporary-directory-non-windows
implement `temporary_directory` on non-windows
2024-07-08 18:25:34 +01:00
Laytan Laats 9ff77397c6 implement temporary_directory on non-windows 2024-07-08 18:58:17 +02:00
gingerBill 48aef50164 Add #load cache files to -export-dependencies:json 2024-07-08 17:46:10 +01:00
gingerBill fc9c995dc4 Fix fmt for code compilation bug with any 2024-07-08 16:39:13 +01:00
gingerBill 564d5af8b2 Default to -o:none for all builds 2024-07-08 16:12:22 +01:00
gingerBill 2c9ef6907a Clean up timings messages showing used module count 2024-07-08 15:30:33 +01:00
gingerBill 505dec7b14 Merge branch 'master' of https://github.com/odin-lang/Odin 2024-07-08 15:13:45 +01:00
gingerBill 2a219fa830 Correct -use-separate-module behaviour 2024-07-08 15:13:40 +01:00
gingerBill 498fb00c25 Merge pull request #3890 from laytan/llvm-18-non-windows-releases
ci: make releases use LLVM 18
2024-07-08 14:57:21 +01:00
Jeroen van Rijn ec2234560a Merge pull request #3889 from laytan/darwin-remove-implicit-syscall-usage
darwin: remove syscall usage (without -no-crt) to comply to Apple guidelines
2024-07-08 15:54:24 +02:00
Laytan Laats 5dd89a29e6 ci: make releases use LLVM 18
Since we updated to LLVM 18 on Windows now, we should make the releases
for non-windows use LLVM 18 too, this way all releases use the same version.
2024-07-08 15:49:37 +02:00
gingerBill 8491e2491c Experiment with different uses of -use-separate-modules 2024-07-08 14:48:59 +01:00
Laytan Laats ddad2011e2 darwin: remove syscall usage (without -no-crt) to comply to Apple guidelines 2024-07-08 15:39:23 +02:00
gingerBill 7dd4cccce7 Use a temporary directory for -use-separate-modules
Windows only currently
2024-07-08 14:21:07 +01:00
gingerBill 0f664893dd Add sort for global types and procedures 2024-07-08 13:59:25 +01:00
gingerBill 04e0b3e270 Merge pull request #3887 from odin-lang/windows-llvm-18
Update to LLVM 18.1.8 for Windows
2024-07-08 13:25:22 +01:00
gingerBill 930a147f24 Update to LLVM 18.1.8 2024-07-08 13:08:18 +01:00
gingerBill 86c58167ed Add -print-linker-flags 2024-07-08 10:40:04 +01:00
Jeroen van Rijn 212906ecd2 Merge pull request #3886 from laytan/cbor-enhancements
CBOR enhancements
2024-07-08 02:01:39 +02:00
Laytan Laats 6ab559437a encoding/cbor: add a custom tag to the example 2024-07-08 01:01:11 +02:00
Laytan Laats db3b4ceb4a encoding/cbor: improve perf of marshalling array-like types 2024-07-08 00:37:40 +02:00
Laytan Laats 39e9b65c59 encoding/cbor: fix umarshal of big fixed arrays 2024-07-08 00:35:19 +02:00
Laytan Laats 56856b6307 io: remove dead code in io.write_at_least 2024-07-08 00:33:50 +02:00
Jeroen van Rijn 861ad2037f Merge pull request #3884 from Feoramund/fix-3883
Forbid `$T=` parameter from crashing compiler
2024-07-06 22:08:05 +02:00
Feoramund 77d64a5461 Forbid $T= parameter from crashing compiler
Fixes #3883
2024-07-06 15:32:17 -04:00
gingerBill 88c9512d5f Merge pull request #3828 from laytan/re-raise-signals-from-odin-run
re-raise signals from the `odin run` binary
2024-07-06 18:55:37 +01:00
Jeroen van Rijn b79a098c2e Merge pull request #3882 from Kelimion/clean_up_iterator
Remove nil checks.
2024-07-06 18:45:45 +02:00
Jeroen van Rijn 258f120d52 Remove nil checks.
The caller should really not pass `foo: ^string = nil`. A `for ch, in foo` would also crash,
so let's not introduce new semantics for iteration.

A caller shouldn't pass garbage if they can help it, and a `nil` ^string is not a useful ZII usage here.
2024-07-06 18:34:52 +02:00
gingerBill 80d122f531 Merge pull request #3879 from caquillo07/hm/adding-missing-env-calls-to-core-os-darwin
Add Darwin setenv and unsetenv syscalls
2024-07-06 12:55:29 +01:00
gingerBill efe5e9e349 Merge pull request #3858 from flysand7/wow64-apiset
Add bindings for WOW64 API set
2024-07-06 00:23:47 +01:00
Jeroen van Rijn 25904e8f89 Merge pull request #3878 from Poaetce/setsid-returns-pid
[sys/linux]: change setsid to return Pid
2024-07-06 01:21:22 +02:00
Hector Mejia 2b854c94da added the setenv and unsetenv bindings for darwin, inspired but os_linux.odin 2024-07-05 16:26:03 -04:00
poa 8c98ca3a10 updated return value of setsid to return Pid 2024-07-05 22:53:45 +09:00
Jeroen van Rijn ecffe5a082 Merge pull request #3877 from Kelimion/wstring_fix
Fix utf8_to_wstring given zero bytes.
2024-07-05 13:58:49 +02:00
Jeroen van Rijn 9ecc33570b Improve fix. 2024-07-05 13:51:38 +02:00
Jeroen van Rijn 164a5e587e Fix utf8_to_wstring given zero bytes. 2024-07-05 13:46:07 +02:00
Jeroen van Rijn c8432df248 Merge pull request #3874 from laytan/fix-not-detecting-duplicate-proc-case
Fix not detecting duplicate proc cases
2024-07-05 01:00:14 +02:00
Laytan Laats f66b7021a6 Fix not detecting duplicate proc cases
Fixes #3864
2024-07-05 00:50:52 +02:00
Jeroen van Rijn 22fabba2f6 Fix #3873 2024-07-05 00:48:08 +02:00
gingerBill c77f5b00bc Merge pull request #3872 from laytan/fix-assertion-failure-on-old-llvm
Fix assertion false negative
2024-07-04 23:27:11 +01:00
Laytan Laats 1bd9fe04c4 Fix assertion false positive
Assertion was added in #3855 - https://github.com/odin-lang/Odin/pull/3855/commits/723314909679b89e159cb4cb05d250d12ac64436
to mimic LLVM's own internal assertion for this, turns out their
assertion is more sophisticated than an `==` so lets just remove it.

To be clear their internal assertion is not hit while this one is, which
defeats the purpose of ours.
2024-07-04 23:55:21 +02:00
Jeroen van Rijn 3c2161b196 Merge pull request #3870 from laytan/fix-fontstash-proc-group
vendor/fontstash: fix 'AddFont' proc group for JS target
2024-07-04 17:05:49 +02:00
Jeroen van Rijn 5247d3749c Merge pull request #3871 from Kelimion/dynlib_temp
Remove implicit allocator usage in `core:dynlib`
2024-07-04 17:05:21 +02:00
Jeroen van Rijn 8bee73b08e Remove implicit allocator usage in core:dynlib 2024-07-04 16:53:00 +02:00
Laytan Laats bcdb202639 vendor/fontstash: fix 'AddFont' proc group for JS target 2024-07-04 16:50:58 +02:00
gingerBill 1eb0bc1408 Remove *_test.odin; always compile it for all targets 2024-07-04 14:43:57 +01:00
gingerBill e9a54666e2 Fix typo. 2024-07-04 14:41:10 +01:00
gingerBill 8b7c6a23ba Restrict a bit more 2024-07-04 14:06:02 +01:00
gingerBill bf711b282d Remove when check in check_entity_from_ident_or_selector 2024-07-04 13:58:36 +01:00
gingerBill 87bccc8f3f Remove import name cases 2024-07-04 13:53:52 +01:00
gingerBill 657bc88535 Allow x :: y when cond else proc(...){...} 2024-07-04 13:48:52 +01:00
gingerBill 45b2a6a19e Fix reflect.as_pointer 2024-07-04 13:37:47 +01:00
gingerBill d78ff0be52 Fix lb_store_type_case_implicit 2024-07-04 13:20:36 +01:00
gingerBill 52c219690a Ff @(disabled=true), do not add that entity's dependencies to the set 2024-07-04 13:09:31 +01:00
gingerBill 053f1759d7 Merge pull request #3866 from DerTee/test_mem_dynamic_pool
add test for mem.dynamic_pool and fix alignment bug
2024-07-03 22:17:57 +01:00
gingerBill b65aa9c439 Merge pull request #3867 from karl-zylinski/error-on-typeof-untyped-type
error on type_of(value of untyped type)
2024-07-03 22:09:59 +01:00
Karl Zylinski 782286357b error on type_of(value of untyped type) 2024-07-03 22:21:32 +02:00
DerTee 6b373cf49e fix #3692 memory alignment bug in core:mem.dynamic_pool_alloc_bytes 2024-07-03 22:14:28 +02:00
DerTee a76f9a70d5 add test for allocator mem.Dynamic_Pool
this test currently fails because of bug #3692
2024-07-03 22:13:20 +02:00
Jeroen van Rijn a276722da5 Merge pull request #3865 from Feoramund/fix-sdl-constants
Fix SDL constants
2024-07-03 21:31:53 +02:00
Feoramund bb6cbf6559 Fix SDL constants 2024-07-03 15:22:39 -04:00
Jeroen van Rijn f6892d2236 Fix help text. 2024-07-03 19:30:25 +02:00
gingerBill 075384b2bb Fix #soa assignment bug 2024-07-03 00:33:13 +01:00
gingerBill 7e6acdf800 Merge pull request #3855 from laytan/master
Fix two LLVM assertion failures
2024-07-02 22:16:49 +01:00
gingerBill 8b49549fd3 Merge pull request #3859 from laytan/wasm-stbtt-object-linking-preopens
wasm: support `vendor:stb/truetype` and `vendor:fontstash`
2024-07-02 22:14:54 +01:00
Jeroen van Rijn 0ceae51223 Merge pull request #3862 from laytan/fix-empty-webgpu-link-errors
vendor/wgpu: fix linker errors with empty project
2024-07-02 23:05:34 +02:00
Laytan Laats 761a50e145 vendor/wgpu: fix linker errors with empty project 2024-07-02 22:37:02 +02:00
Laytan Laats 5399093050 make preopens a slice and remove bad current_dir 2024-07-02 20:17:24 +02:00
Laytan Laats 0ef5191540 use slice.ptr_swap instead of alloca 2024-07-02 20:11:44 +02:00
Laytan Laats 10c68a8951 wasm: support vendor:stb/truetype and vendor:fontstash 2024-07-02 16:03:42 +02:00
Laytan Laats 4e18e1b191 wasi: make os.open work with absolute paths 2024-07-02 15:29:24 +02:00
Laytan Laats 6f1cc8071c wasm: add foreign import and linking of wasm object files 2024-07-02 15:28:08 +02:00
flysand7 41282b5211 Add bindings for WOW64 API set 2024-07-02 21:56:04 +11:00
Jeroen van Rijn 0697fd0101 Merge pull request #3857 from flysand7/tlhelp-modentry
[sys/windows]: Fix the type declaration for MODULEENTRY32W
2024-07-02 12:42:18 +02:00
flysand7 62d107bea5 [sys/windows]: Fix the type declaration for MODULEENTRY32W 2024-07-02 21:34:54 +11:00
Andreas T Jonsson b26f4e0766 Use pkgsrc llvm for NetBSD CI 2024-07-02 11:43:01 +02:00
Laytan Laats 7233149096 fix llvm assertion failure when const initializer is not the same type 2024-07-02 01:25:52 +02:00
Laytan Laats c822f0b8c8 fix llvm assertion about metadata on non-instruction 2024-07-02 01:14:50 +02:00
Jeroen van Rijn d912c6e320 Merge pull request #3849 from Feoramund/zero-mantissa
Don't factor trailing zeroes into mantissa division
2024-07-01 20:53:07 +02:00
Jeroen van Rijn f7243eac74 Force cl.exe to parse Odin source as utf-8. 2024-07-01 20:48:00 +02:00
Jeroen van Rijn c2ab2bf25a Add UTF-8 BOM for ucg.c, because reasons. 2024-07-01 20:23:48 +02:00
ed fd7af9a078 Merge tag 'dev-2024-07' 2024-07-01 13:32:04 -04:00
gingerBill b4ca044ae0 Merge pull request #3846 from Feoramund/add-more-net-tests
Add more `core:net` tests
2024-07-01 17:56:07 +01:00
gingerBill a2b23de0a7 Sanity check for a nullptr 2024-07-01 12:24:46 +01:00
gingerBill 42ff711114 Fix #3515 2024-07-01 12:22:18 +01:00
gingerBill 544959326b Add intrinsics.type_struct_has_implicit_padding #3844 2024-07-01 12:13:35 +01:00
gingerBill 942f3f5220 Add non_zero_* variants for #soa dynamic array 2024-07-01 12:04:29 +01:00
gingerBill 8ddfcf174d Add #soa support to append directly 2024-07-01 11:51:28 +01:00
gingerBill 4086a62167 Fix showing error when not meant to 2024-07-01 11:50:35 +01:00
gingerBill 3a43928184 Add #no_broadcast to append_soa 2024-07-01 11:47:33 +01:00
gingerBill 7f6fe91896 Add #soa forms to reserve, clear, and resize 2024-07-01 11:37:21 +01:00
gingerBill 11617af8f5 Add support for make(#soa[]T) etc 2024-07-01 11:34:50 +01:00
gingerBill 4a2b87672c Unify #soa code for structs and arrays 2024-07-01 11:11:06 +01:00
gingerBill fb0b95bcad Merge pull request #3760 from Feoramund/refactor-show-error-on-line
Refactor `show_error_on_line`
2024-07-01 11:03:29 +01:00
gingerBill 1a4edad63e Merge pull request #3848 from laytan/wasm-c-abi-indirect-multifield-struct
make structs with multiple fields always return indirect in wasm c abi
2024-07-01 11:02:49 +01:00
Feoramund 8cd7fd95a3 Don't factor trailing zeroes into mantissa division
This should fix issues where `N00 / (pow+2)` results in a different number
than `N / pow`.
2024-06-30 22:18:25 -04:00
Laytan Laats ef6a73c7ef fix not setting cc before using it in abi computations 2024-07-01 01:30:44 +02:00
Laytan Laats e3dde8caf8 make structs with multiple fields always return indirect in wasm c abi 2024-07-01 00:50:10 +02:00
Feoramund 8e64265aed Replace unneeded transmute 2024-06-30 16:39:22 -04:00
Feoramund 1e7dfd0e34 Add more core:net tests
- UDP send & read
- DNS resolution
- Nonblocking socket option
2024-06-30 16:39:22 -04:00
gingerBill 13ace1dac9 Merge pull request #3839 from flysand7/tlhelp-fix
[sys/windows]: Fix the value for TH32CS_SNAPPROCESS constant
2024-06-30 20:15:33 +01:00
Jeroen van Rijn efd933e221 Merge pull request #3842 from karl-zylinski/fix-poly-bitset-size
Fix for bit_set[$T] proc params always being generated as i8
2024-06-30 21:10:42 +02:00
Karl Zylinski e0face1ac8 Make types like bit_set[$T] have their upper and lower bits overwritten by upper/lower from the source types when checking if polymorphic type is assignable. This fixes an issue where an i8 was always generated for bit_sets with generic elements, because it couldn't figure out upper/lower when check_bit_set_type was run. Fixes #2860 2024-06-30 20:36:51 +02:00
Feoramund 8b915aae5e Update code for new -vet 2024-06-30 11:18:40 -04:00
Feoramund f0cf1052d0 Fix FreeBSD recvfrom
`fromlen` must be a pointer, not a value.
2024-06-30 10:17:32 -04:00
Jeroen van Rijn 4fbd22b668 Merge pull request #3840 from H0mTanks/master
Add missing enum member for WSAEWOULDBLOCK in TCP_Send_Error for windows.
2024-06-30 11:29:31 +02:00
h0mtanks 2b615b09f0 fixed whitespace 2024-06-30 13:47:11 +05:30
h0mtanks d1603ebac4 added missing would_block enum member 2024-06-30 13:42:55 +05:30
flysand7 561b96b20d [sys/windows]: Fix the value for TH32CS_SNAPPROCESS constant 2024-06-30 13:34:08 +11:00
gingerBill afe24a0d4d Merge pull request #3838 from flysand7/windows-tlhelp
[core/windows]: Bind tlhelp.h functions from kernel32.dll
2024-06-30 02:52:35 +01:00
flysand7 2737ccab3d [core/windows]: Bind tlhelp.h functions from kernel32.dll 2024-06-30 12:35:42 +11:00
Feoramund 8ed5cb283b Re-implement the error squiggles with visual width 2024-06-29 18:55:12 -04:00
Feoramund 8b305a4c67 Add UCG library to Odin compiler 2024-06-29 18:42:56 -04:00
gingerBill 80592f0f51 Add -disallow-do in CI 2024-06-29 22:50:23 +01:00
gingerBill af3401631a Remove the -disallow-do aspect from -strict-style 2024-06-29 22:48:43 +01:00
gingerBill 5637ed9ecd Merge pull request #3836 from laytan/run-wasi-demo-in-ci
wasi: make the demo run on wasi and run it in CI
2024-06-29 22:30:31 +01:00
Laytan Laats 604551eb2d wasi: make the demo run on wasi and run it in CI 2024-06-29 23:15:31 +02:00
Jeroen van Rijn 476d0087c8 Fix bug in div3 fast path. 2024-06-29 23:14:12 +02:00
gingerBill 34fce83d66 Improve -strict-style rules for if-else statements 2024-06-29 20:04:34 +01:00
gingerBill b1a1da6618 Add -vet-tabs 2024-06-29 19:54:31 +01:00
gingerBill e296d6fb90 Fix loads of indentation issues with mixing spaces and tabs 2024-06-29 19:50:51 +01:00
gingerBill 90244a0849 Fix accidental deletion in the -strict-style help comment 2024-06-29 19:41:45 +01:00
gingerBill f4abdf716e Move microarch stuff to a separate file 2024-06-29 19:29:20 +01:00
gingerBill f64d1df90b Add note regarding -strict-style 2024-06-29 19:27:26 +01:00
gingerBill 888bf28076 -strict-style implies -disallow-do 2024-06-29 19:26:11 +01:00
gingerBill 103eccf104 More style improvements 2024-06-29 19:23:58 +01:00
gingerBill 663661db53 Update core to -strict-style 2024-06-29 19:16:32 +01:00
gingerBill 835e8bf87a Update -strict-style 2024-06-29 19:15:33 +01:00
gingerBill 2187f3e7ff -strict-style enforce 1TBS (mostly) 2024-06-29 19:14:24 +01:00
gingerBill 5413a8b744 Even more style fixes 2024-06-29 19:11:36 +01:00
gingerBill 3f9a58808c More style improvements 2024-06-29 19:07:34 +01:00
gingerBill e8517e2694 -strict-style: enforce case to be in the same column as switch 2024-06-29 18:56:45 +01:00
gingerBill 96330996a6 Fix indentation 2024-06-29 18:51:39 +01:00
gingerBill b0cbda4ee0 Fix indentation of tests 2024-06-29 18:51:28 +01:00
gingerBill 930c929294 Indentation fixes 2024-06-29 18:49:57 +01:00
gingerBill 7f05b4caf2 Fix generation for unicode entities 2024-06-29 18:43:09 +01:00
gingerBill 6db748b4a4 Remove debug message 2024-06-29 16:18:43 +01:00
gingerBill a935ade0d2 Keep -sanitize:address happy with bit_field loads 2024-06-29 16:18:07 +01:00
gingerBill ff2d042313 Remove unneeded transmute 2024-06-29 13:54:15 +01:00
gingerBill 913c08a33e Add bit_field to demo.odin 2024-06-29 12:56:46 +01:00
gingerBill c88a1bef91 Add another -vet-cast check 2024-06-29 12:40:04 +01:00
gingerBill 706adb1232 Update for transmute -vet-cast 2024-06-29 12:16:43 +01:00
gingerBill b9861a0cf6 cast to transmute 2024-06-29 12:14:21 +01:00
gingerBill e46d772b6d Add check for integer casts 2024-06-29 12:13:41 +01:00
gingerBill c18c0a3364 Adhere to -vet-cast 2024-06-29 12:07:21 +01:00
gingerBill d6b8544f50 Add internal flag for testing stuff 2024-06-29 12:04:31 +01:00
gingerBill 4b71c47fd5 Check for unneeded transmute with -vet-cast 2024-06-29 12:02:31 +01:00
gingerBill 704530497b Rename -vet-identical-cast to -vet-cast; with minor code clean up 2024-06-29 11:44:45 +01:00
gingerBill 4be0fc05bb Merge pull request #3832 from Feoramund/vet-identical-cast
Add `-vet-identical-cast`
2024-06-29 11:37:35 +01:00
gingerBill 52aa7085e4 Use f32 as the immediate type for addition and subtraction for complex32/quaternion64 2024-06-29 11:09:54 +01:00
gingerBill 9113f389d8 Merge pull request #3831 from Feoramund/fix-darwin-test-runner-cancel
Let Darwin safely panic in a test
2024-06-29 11:01:01 +01:00
gingerBill 55e9b8d994 Use explicit calling conventions 2024-06-29 10:48:41 +01:00
gingerBill ee2a0c4010 Merge branch 'master' of https://github.com/odin-lang/Odin 2024-06-29 10:47:15 +01:00
gingerBill f974002839 Use f32 operations rather than f16 in complex32 and quaternion64 to improve accuracy and performance 2024-06-29 10:47:09 +01:00
gingerBill 83b575aec2 Merge pull request #3833 from karl-zylinski/consistent-default-dynamic-array-capacity
Consistent dynamic array default capacity and avoid unnecessary dynamic array allocations
2024-06-29 10:38:22 +01:00
gingerBill 906afa4154 Allow for when x in y { (minor oversight in syntax) 2024-06-29 10:13:15 +01:00
Karl Zylinski 679f9b4e41 Made default capacity of dynamic arrays more consistent.
Before this if you do `arr: [dynamic]int` and then append to arr, then it will have capacity 8.
But if you did `arr := make([dynamic]int, context.temp_allocator)` then arr would have capacity 16.

Now both `arr: [dynamic]int` and `arr := make([dynamic]int, context.temp_allocator)` will resut in arr having zero 0. The only reason to use `make` without an explicit len or cap now is because you want to set it up for a non-default allocator. After the first call to `append` it will now in both cases have capacity 8.

I also updated the documentation on the strings builder, both to reflect this, and also to fix it incorrectly saying that len would be 'max(16,len)', which wasn't true even before these changes.
2024-06-29 08:57:21 +02:00
Feoramund b3caae6db4 Keep -vet happy 2024-06-28 23:14:03 -04:00
Feoramund 6496432b80 Add -vet-identical-cast 2024-06-28 23:14:03 -04:00
Feoramund 0ea0fac2f9 Call pthread_cancel on Darwin, with advisory comment 2024-06-28 20:47:37 -04:00
Feoramund 13539d3be1 Catch SIGTRAP in the test runner
Fixes `panic` for Darwin.
2024-06-28 19:43:03 -04:00
Feoramund 929cc48703 Merge Darwin signals into other UNIX-likes
They're all the same.
2024-06-28 19:03:43 -04:00
Jeroen van Rijn 06652bebce Merge pull request #3829 from Feoramund/fix-vetted-test-name
Let `-vet` be used with `-define:ODIN_TEST_NAMES`
2024-06-28 23:06:25 +02:00
Feoramund 574342af6f Let -vet be used with -define:ODIN_TEST_NAMES 2024-06-28 15:58:22 -04:00
Laytan Laats fa5be93da2 re-raise signals from the odin run binary 2024-06-28 19:33:34 +02:00
Jeroen van Rijn 007832488d Merge pull request #3827 from Feoramund/require-runtime-linalg-import
Require `base:runtime` import in `core:math/linalg`
2024-06-28 17:44:10 +02:00
Feoramund 2af121752a Require base:runtime import in core:math/linalg 2024-06-28 11:34:35 -04:00
gingerBill 0c8924ea85 Merge pull request #3822 from jasonKercher/os2-rebase
os2 linux round 2
2024-06-28 15:43:18 +01:00
jason 6a894195cb revert os2/process 2024-06-28 09:45:22 -04:00
jason dc954307d7 fix assumption about std handles in os2/file.odin 2024-06-28 07:55:33 -04:00
jason a15cbc474d change error strings to an enumerated array in rodata; print_error takes a file argument 2024-06-28 07:45:24 -04:00
gingerBill 37afd469c6 Merge pull request #3339 from axxeny/patch-1
fix comments in core:container/queue.
2024-06-28 12:00:34 +01:00
gingerBill 853173a11b Merge pull request #3517 from timosperisen/patch-1
Update builder.odin
2024-06-28 12:00:23 +01:00
gingerBill a1ae6f161b Merge pull request #3502 from ARtemachka/master
Fix typo in core_builtin
2024-06-28 12:00:10 +01:00
gingerBill 883f6c129a Merge pull request #3643 from korvahkh/fix-omitempty-comma
encoding/json: Fix struct marshal() emitting comma after omitted field
2024-06-28 11:50:31 +01:00
gingerBill 861d51b760 Merge pull request #3825 from Valakor/wgpu
wgpu_native fixes
2024-06-28 11:49:35 +01:00
gingerBill 17efb87eef Add -custom-attribute 2024-06-28 11:44:39 +01:00
gingerBill 1747fdc3f0 Fix signature 2024-06-28 11:07:54 +01:00
gingerBill bef3ca98f0 Fix signature 2024-06-28 11:01:57 +01:00
gingerBill e15c5c4692 Fix missing import 2024-06-28 10:32:16 +01:00
gingerBill 9a4ffa79db Add missing libraries to examples/all 2024-06-28 10:17:00 +01:00
gingerBill ec38215842 Fix #3803 2024-06-28 10:09:46 +01:00
gingerBill 67e9a6fd9b Improve error reporting on "Failed to parse fail" and show the line error if possible 2024-06-28 10:04:08 +01:00
gingerBill 4824050c99 Merge pull request #3792 from Feoramund/core-uuid
Add `core:encoding/uuid`
2024-06-28 09:49:23 +01:00
gingerBill 35651cfc17 Improve tokenization for false integer literals but not effect possible float literals 2024-06-28 09:24:34 +01:00
gingerBill dde7cb6e7f Improve error message for #3754 2024-06-28 09:21:33 +01:00
gingerBill 862a04376f Improve tokenizing wrong number literals 2024-06-28 09:16:01 +01:00
gingerBill 5a9698e8cb Properly fix #3820 2024-06-28 09:08:57 +01:00
gingerBill 0c8a81d298 Fix #3819 2024-06-28 08:57:31 +01:00
gingerBill 06ff08b9cf Fix #3820 2024-06-28 08:53:05 +01:00
gingerBill 52ea63f89c Fix #3471 2024-06-28 08:43:25 +01:00
gingerBill f883cd5053 Initialize default context in heap_allocator_other.odin 2024-06-28 08:33:12 +01:00
Matthew Pohlmann 4bf9de7237 SupportedLimitsExtras.chain should be a ChainedStructOut to properly chain from SupportedLimits 2024-06-27 21:53:16 -07:00
Matthew Pohlmann 0a504c2647 Some fixes to wgpu_native.
1. LogCallback should have the "c" calling convention and takes a
   userdata pointer like other callbacks.
2. DevicePoll's wrappedSubmissionIndex argument is an optional in/out
   parameter. The previous wrapper method was broken since it passed a
   non-nil structure to the underlying API with invalid members.
2024-06-27 21:41:48 -07:00
Jeroen van Rijn d31f88bfaa Merge pull request #3823 from laytan/enforce-global-foreign-import-variables
disallow non-global foreign import of variables on wasm
2024-06-28 02:11:50 +02:00
Laytan Laats b79d7e6917 disallow non-global foreign import of variables on wasm 2024-06-28 01:34:09 +02:00
Jeroen van Rijn ed7d34beb0 Avoid sporadic wasm crash 2024-06-28 00:39:51 +02:00
Jeroen van Rijn aba274cf75 Merge pull request #3821 from Kelimion/clang_override
Allow `ODIN_CLANG_PATH=clang-path` overrides for link stage.
2024-06-27 23:36:39 +02:00
Jeroen van Rijn 140ee036ce wasm error is no longer relevant 2024-06-27 23:29:36 +02:00
Jeroen van Rijn 58cd75350b Allow ODIN_CLANG_PATH=clang-path overrides
Link using `clang`, unless overridden by `ODIN_CLANG_PATH` environment variable.

Fixes #3783
2024-06-27 23:21:58 +02:00
jason f24f72c280 convert all to use sys/linux over sys/unix; new implementations for pipe, process and env 2024-06-27 17:14:48 -04:00
jason f22754fc90 sys/linux: fix some syscalls and types; add more to Sig_Action and Sig_Info; Pid int->i32 2024-06-27 16:29:47 -04:00
Jeroen van Rijn a0a48bfe34 Fix alignment. 2024-06-27 21:56:26 +02:00
Jeroen van Rijn 9f8b84c212 Merge pull request #3815 from laytan/tlsf-fixes
tlsf: destroy first pool & properly zero memory
2024-06-27 19:50:24 +02:00
Laytan Laats 1c199f52d6 tlsf: destroy first pool & properly zero memory 2024-06-27 19:27:07 +02:00
gingerBill 521182a100 Merge pull request #3813 from tadeohepperle/fix-vulkan-codegen-arrays-as-proc-args
Fix `vender:vulkan` codegen for procedures with fixed size arrays are arguments
2024-06-27 16:34:17 +01:00
Jeroen van Rijn aa27cd4b0b Allow core:odin to parse @(require) import 2024-06-27 16:14:16 +02:00
ed 4a072b8f4e Merge remote-tracking branch 'offical/master' 2024-06-26 23:24:48 -04:00
gingerBill b1d06ea03f Merge pull request #3808 from karl-zylinski/fix-append-elem-max-confusion
Replace `max(8, 1)` in _append_elem with just `8` and a comment.
2024-06-26 21:14:08 +01:00
Jeroen van Rijn e37afa3ada Merge pull request #3814 from Kelimion/fix_fixed
Fix core:math/fixed.
2024-06-26 20:46:46 +02:00
Tadeo hepperle b834bd32f5 fix typo 2024-06-26 20:31:43 +02:00
Jeroen van Rijn 3726f0b73c Merge pull request #3812 from Feoramund/add-table-decorations
Add `write_decorated_table` to `text/table`
2024-06-26 20:15:11 +02:00
Jeroen van Rijn c33bf7673f Fix core:math/fixed. 2024-06-26 20:12:55 +02:00
Tadeo hepperle 67e69f7196 Merge branch 'master' into fix-vulkan-codegen-arrays-as-proc-args 2024-06-26 19:31:00 +02:00
Tadeo hepperle 18dadd94e3 fix proc parsing 2024-06-26 19:30:21 +02:00
Feoramund ba354e0524 Add documentation for write_decorated_table 2024-06-26 12:53:34 -04:00
Feoramund f13d30ad23 Add write_decorated_table API 2024-06-26 12:50:43 -04:00
Feoramund ba05c74936 Enable core:net tests for FreeBSD 2024-06-26 10:05:24 -04:00
Feoramund e61d893a74 Port core:net to FreeBSD 2024-06-26 10:05:24 -04:00
Feoramund 10ce76fcc2 Fix FreeBSD futex implementation
- Add missing size of timeout struct to `_umtx_op`.
- Use `WAIT_UINT` not `WAIT`, as the expected value is an unsigned integer.
- Use new native calls instead of libc.
2024-06-26 10:02:07 -04:00
Feoramund c61f5bbfe7 Add core:sys/freebsd 2024-06-26 10:02:06 -04:00
Jeroen van Rijn 8d1827838f Merge pull request #3807 from karl-zylinski/ctprint
Added fmt.ctprint
2024-06-25 22:52:48 +02:00
Karl Zylinski f227a40652 Replace max(8, 1) in _append_elem with just 8 and a comment. 2024-06-25 22:48:14 +02:00
Karl Zylinski 4e2d12c540 Added fmt.ctprint 2024-06-25 22:32:20 +02:00
Jeroen van Rijn 5d1d98cef3 Merge pull request #3806 from NicknEma/windows_fixes
Update CommandLineToArgvW return type
2024-06-25 12:22:27 +02:00
NicknEma 845613c404 Update CommandLineToArgvW return type
It now returns a multi-pointer so it can be iterated without any casting.
2024-06-25 12:10:17 +02:00
gingerBill 93441a043a Make runtime.heap_alloc contextless 2024-06-25 09:38:49 +01:00
gingerBill c098739484 Remove @(warning) and #warning(...) 2024-06-25 09:36:59 +01:00
Jeroen van Rijn e42029c5ed wgpu ld -> dl 2024-06-25 01:35:26 +02:00
Jeroen van Rijn d97fe41834 Mark deux 2024-06-24 22:45:12 +02:00
Jeroen van Rijn d3d73590d3 Fix CSV comments. 2024-06-24 22:43:14 +02:00
Jeroen van Rijn 185e39e53d Merge pull request #3791 from Feoramund/fix-text-table-alignment
Refactor `core:text/table`
2024-06-24 21:59:33 +02:00
Feoramund 8b05ec1765 Add string caching example documentation 2024-06-24 15:11:43 -04:00
Feoramund fbd609fa37 Add complete example showcasing Unicode support 2024-06-24 15:04:45 -04:00
Feoramund f325a08e57 Make core:text/table examples more complete
They should be completely copy-and-paste friendly now, without the
assumption of someone using `using table`.
2024-06-24 15:04:45 -04:00
Feoramund 7a43404ea1 Add Width_Proc documentation 2024-06-24 15:04:45 -04:00
Feoramund 7da96c484d Remove table.dirty 2024-06-24 14:28:05 -04:00
Feoramund e397bdf11d Let WIDTH_PROC be specified as proc argument to write_*_table 2024-06-24 13:38:59 -04:00
Feoramund 67b4cb0038 Crunch the ranges 2024-06-24 13:18:54 -04:00
Jeroen van Rijn 8eafd9eb82 wgpu import 2024-06-23 22:19:29 +02:00
Feoramund ca58d7771b Use new API from_nanoseconds in uuid 2024-06-22 18:36:42 -04:00
Feoramund 8a4a3ed66e Change how Time is constructed in uuid 2024-06-22 18:21:32 -04:00
Feoramund 4481f9c695 Clarify some uuid legacy documentation 2024-06-22 18:21:32 -04:00
Feoramund 5a75cac5b9 Add API for creating custom version 8 UUIDs 2024-06-22 18:21:32 -04:00
Feoramund e9b882be05 Add vendor-specific version 8 UUID generation (hashing) 2024-06-22 18:21:32 -04:00
Feoramund 859cbf7d72 Test if v1 and v6 UUID node is set correctly 2024-06-22 18:21:32 -04:00
Feoramund d559feb701 Add uuid test for timestamps 2024-06-22 18:21:32 -04:00
Feoramund f6344577d3 Add UUID sorting tests 2024-06-22 18:21:32 -04:00
Feoramund 339b2b23f6 Add unsafe_write to uuid package 2024-06-22 18:21:32 -04:00
Feoramund 8b8f8c7f7d Address minor organizational issues 2024-06-22 18:21:32 -04:00
Feoramund 95a9c9b016 Fix indentation 2024-06-22 18:21:32 -04:00
Feoramund 9b3a104640 Add buffer-based to_string to uuid package 2024-06-22 18:21:32 -04:00
Feoramund 9b265b2309 Improve time-related API in uuid package
- Let timestamps be specified by the user.
- Change `time_v*` to `raw_time_v*` and implement an API that returns
  timestamps from the `time` package.
2024-06-22 18:21:32 -04:00
Feoramund ea771d0cb7 Update uuid package documentation 2024-06-22 18:21:31 -04:00
Feoramund fcdba334ea Require CSPRNG in UUID generation where applicable 2024-06-22 18:21:31 -04:00
Feoramund 3aa232a894 Move v3 and v5 UUID procs to uuid/legacy 2024-06-22 18:21:31 -04:00
Feoramund 9866b54d59 Add version 6 UUID generation 2024-06-22 18:21:31 -04:00
Feoramund 525bfca4ef Add version 1 UUID generation 2024-06-22 18:21:31 -04:00
Feoramund 4cfbd83b10 Add version 7 UUID generation 2024-06-22 18:21:31 -04:00
Feoramund fee81985b4 Make UUID namespaces @(rodata) 2024-06-22 18:21:31 -04:00
Feoramund 6da99b888a Make UUID Identfier only a distinct byte array 2024-06-22 18:21:31 -04:00
Feoramund 31873ed466 Fix wrong comments 2024-06-22 18:21:31 -04:00
Feoramund 4dacddd85e Add core:encoding/uuid 2024-06-22 18:21:27 -04:00
Jeroen van Rijn 3af9d31bd5 Add time.from_nanoseconds 2024-06-23 00:19:24 +02:00
Jeroen van Rijn dae9a8dfff Merge pull request #3796 from Feoramund/fix-lack-of-str-arg-or-cont
Fix print segfault by missing argument in `or_*` shadowed error
2024-06-22 17:57:02 +02:00
Feoramund f58eded5d2 Fix print segfault by missing argument in or_* shadowed error 2024-06-22 11:45:43 -04:00
Jeroen van Rijn 13c58948f4 Merge pull request #3793 from Kelimion/build_test_only
Add `-build-mode:test`
2024-06-21 16:12:13 +02:00
Jeroen van Rijn 9f696a646f Add -build-mode:test. 2024-06-21 16:02:55 +02:00
gingerBill bad4a6237e Delete misc/roadmap.md 2024-06-21 00:02:12 +01:00
Feoramund bf44a94065 Update core:text/table documentation 2024-06-20 18:22:03 -04:00
Feoramund 82d92dc46c Use log.error instead of eprintf 2024-06-20 17:53:45 -04:00
Feoramund b81458073e Add new API to core:text/table
- `header/row_of_values`, same `header/row`, more verbose name
- `aligned_header/row_of_values`, set alignment for an entire row
- `header/row_of_aligned_values`, set alignment per value
2024-06-20 17:53:45 -04:00
Feoramund 585747bbbf Clarify error message 2024-06-20 17:53:34 -04:00
Feoramund 99c955d124 Remove unneeded loc argument 2024-06-20 15:26:00 -04:00
Feoramund fd28199178 Optimize printing of markdown tables
Check only once if the table has a header row, instead of every row.
2024-06-20 15:01:09 -04:00
Feoramund dd099d9dd6 Add Unicode support to core:text/table 2024-06-20 15:01:09 -04:00
Feoramund 2241ca8e72 Use tabs to indent HTML tables 2024-06-20 13:06:32 -04:00
Feoramund b66b960e7e Don't build HTML tables
`build` only recalculates length and width information, and this is not
needed for HTML tables.
2024-06-20 13:06:32 -04:00
Feoramund 4a3684c5e8 Rename write_ascii_table to write_plain_table 2024-06-20 13:06:28 -04:00
Jeroen van Rijn 91cc006e8f Fix unaligned store for rand 2024-06-20 17:54:37 +02:00
Jeroen van Rijn ac4577ca66 Merge pull request #3790 from Feoramund/optimize-common-rng-dest-size
Optimize default RNG for the common case
2024-06-20 17:41:13 +02:00
Feoramund 1dfc89567e Optimize default RNG for the common case 2024-06-20 11:27:51 -04:00
gingerBill 28e33d86de Merge pull request #3776 from IllusionMan1212/os2-read-fix
fix(os2): check for 0 bytes read and return EOF
2024-06-20 15:37:41 +01:00
gingerBill dab3c832e0 Add #warning(<string>) builtin compile time procedure 2024-06-20 15:32:30 +01:00
Jeroen van Rijn 94a8c38d86 Add GetNumberOfConsoleInputEvents 2024-06-20 15:19:25 +02:00
ed f5d28b84e2 Merge remote-tracking branch 'offical/master'
# Conflicts:
#	src/check_builtin.cpp
2024-06-20 08:58:03 -04:00
gingerBill 8c760e140f Move import to a windows specific file 2024-06-20 12:38:09 +01:00
gingerBill 3db7780a2c Add vendor:wgpu to examples/all 2024-06-20 12:20:06 +01:00
gingerBill 8b446fc88d Fix wgpu paths for Windows 2024-06-20 12:18:26 +01:00
gingerBill c9884906d9 Add #directory 2024-06-20 12:15:55 +01:00
gingerBill 5dc98336a8 Merge pull request #3524 from Feoramund/freebsd-amd64-syscall-errno
Add `intrinsics.syscall_bsd`
2024-06-20 11:47:01 +01:00
gingerBill 23351ca8be Merge pull request #3137 from laytan/show-defineable
Add flags to show/export defineable values and warn if a -define is unused in the project
2024-06-20 11:45:52 +01:00
gingerBill 56383e45a7 Fix #3768 2024-06-20 11:44:00 +01:00
gingerBill 7184792f7a Merge pull request #3740 from laytan/wgpu
Add `vendor:wgpu`
2024-06-20 11:39:58 +01:00
gingerBill d4aa6c3288 Merge pull request #3788 from Beefster09/builder-utils
Add to_cstring for Builders
2024-06-20 11:34:03 +01:00
gingerBill 7703bc595c Merge pull request #3789 from Feoramund/unicode-annex-11
Measure `East_Asian_Width` during grapheme decoding
2024-06-20 11:32:06 +01:00
Feoramund e620645a03 Measure East_Asian_Width during grapheme decoding 2024-06-19 22:35:36 -04:00
Justin Snyder 1a6bb59125 drop unnecessary defer 2024-06-19 18:25:42 -06:00
Justin Snyder 271782d2f4 fix typo
apparently i had a moment of dyslexia
2024-06-19 17:53:34 -06:00
Justin Snyder 1b7c4c2efe trim added null byte 2024-06-19 17:35:16 -06:00
Jeroen van Rijn 4380934283 Merge pull request #3787 from jasonKercher/more-windows-comm
Add more bindings for comm ports and console events
2024-06-19 23:32:12 +02:00
Jeroen van Rijn 21806e5fa5 Merge pull request #3786 from fabiansperber/fix-d3d11-infoqueue
Fix d3d11 IInfoQueue_VTable & Add LoadLibraryExW
2024-06-19 23:26:40 +02:00
jason 93e67f6bec make -strict-style happy 2024-06-19 17:15:09 -04:00
jason 6b1e76985c move DCB to types.odin; add more bindings for comm functions 2024-06-19 17:04:18 -04:00
Fabian Sperber 0e9bf86123 Fix d3d11 IInfoQueue_VTable & Add LoadLibraryExW
- wrong order & was missing PushStorageFilter & PushRetrievalFilter
2024-06-19 22:22:26 +02:00
Justin Snyder 8f2c4a7ecf Add builder to_cstring 2024-06-19 11:55:19 -06:00
jason e6d84d18d3 Merge remote-tracking branch 'origin/master' into more-windows-comm 2024-06-19 12:33:13 -04:00
jason a9b6d28291 save before merging from upstream 2024-06-19 12:33:05 -04:00
Jeroen van Rijn 2797dc6452 Merge pull request #3785 from mgavioli/new_i18n_API
Separate I18N calls for immutable and for pluraliseable strings. Fixes #3687
2024-06-19 11:50:24 +02:00
Jeroen van Rijn 322b7f1f2f Spell check i18n.odin. 2024-06-19 11:41:58 +02:00
Jeroen van Rijn e0de52efa1 Spell check doc.odin. 2024-06-19 11:15:17 +02:00
Maurizio M. Gavioli 53755824fb Separate the I18N calls for immutable strings and for pluraliseable strings.
Also update tests.
2024-06-19 10:10:26 +02:00
Jeroen van Rijn 7064166da2 Merge pull request #3767 from Feoramund/use-rng-context-in-test-runner
Setup `context.random_generator` in test runner
2024-06-19 09:51:13 +02:00
Feoramund d4803583ff Work around Windows test failure
I am uncertain why this works, but it does. Previously, `rtti_test` was
failing due to non-zero data appearing in the `l_buggy` `Buggy_Struct`.

The issue was caused by calling `runtime.default_random_generator` with
a pointer to the state, somehow. The pointer could be on the stack or in
the heap; it did not matter.

I found two workarounds.

- One is to move the RNG setup behind the call to `free_all`.
- The other is to construct the random generator manually.

Despite my digging and testing, I could find no reason as to why this
works or what the fundamental issue was to begin with. If anyone comes
upon this in the future with direct access to a Windows machine, I
recommend stepping through the program with a debugger to investigate
more deeply into why this happens.
2024-06-18 23:21:04 -04:00
Jeroen van Rijn dff8a9153e Merge pull request #3781 from Feoramund/add-missing-test-imports
Add missing imports to `core` test suite
2024-06-18 18:20:02 +02:00
Feoramund e3f4772d01 Fix removal of temporary file in core:flags test 2024-06-18 11:06:49 -04:00
IllusionMan1212 c987b964c8 fix(os2): check for 0 bytes read and return EOF 2024-06-18 17:03:54 +02:00
Feoramund 6b25d17ef9 Add missing imports to core test suite 2024-06-18 10:38:43 -04:00
gingerBill 3d9db56410 Minor formatting changes to unicode stuff 2024-06-18 12:53:56 +01:00
gingerBill 02cd53d42c Merge pull request #3700 from Feoramund/core-flags
Add package `core:flags`
2024-06-18 12:48:57 +01:00
gingerBill de23965ecb Merge pull request #3775 from Feoramund/unicode-graphemes
Add grapheme analysis facilities to `core:unicode`
2024-06-18 12:48:31 +01:00
gingerBill e8c17ac356 Merge pull request #3778 from Feoramund/fix-2824
Allow custom `main` when `-no-entry-point` is set
2024-06-18 12:46:33 +01:00
gingerBill dc03e8380d Merge pull request #3779 from karl-zylinski/clarify-usage-of-temp-allocator-arena
Clarify when the arena in base:runtime should be used
2024-06-18 12:45:43 +01:00
Jeroen van Rijn aad7ddf2d1 Merge pull request #3780 from destroycomputers/fix/rbtree/key-ordering-constraint
Loosen constraint on the Key type in rb & avl tree
2024-06-18 13:42:36 +02:00
destroycomputers de44dd5412 Loosen constraint on the Key type in rb & avl tree
The current constraint on the `init_ordered' function accepts only
numeric types. While one still can init a non-numerically-keyed tree by
passing a comparator explicitly, the reason to disallow non-numeric
ordered types is nowhere to be found.
2024-06-18 13:31:45 +02:00
Karl Zylinski 11e586494b Clarify that the arena in base:runtime shouldn't be used for anything but the default temp allocator. This is done by renaming the file in which it lives, and also by improving the comment above Arena :: struct {. This should avoid some confusion where people end up using the Arena in base:runtime because they thought it was the 'default arena'. 2024-06-18 12:48:16 +02:00
Jeroen van Rijn dd364c0c0f Merge pull request #3777 from Feoramund/fix-3047
Forbid private test cases
2024-06-18 12:09:58 +02:00
Feoramund 0196cc46e3 Allow custom main when -no-entry-point is set 2024-06-18 01:49:55 -04:00
Feoramund eb5a66c944 Forbid private test cases 2024-06-18 01:28:05 -04:00
Feoramund 9e4899d35c Add tests for decode_grapheme_clusters 2024-06-17 21:57:32 -04:00
Feoramund 63973f431e Make core:unicode letter procs @(require_results) 2024-06-17 21:57:32 -04:00
Feoramund 1620a69398 Add decode_grapheme_clusters to core:unicode/utf8 2024-06-17 21:57:32 -04:00
Feoramund 1a93dfd28f Fix indentation 2024-06-17 13:24:47 -04:00
gingerBill f280ba8511 Merge pull request #3756 from matias-eduardo/empty_structs_hash_fmt
Handle empty structs in hash (#v) fmt
2024-06-16 19:54:28 +01:00
Jeroen van Rijn a66ce4f871 Merge pull request #3773 from Kelimion/res_path_bug
Fix `rc.exe` bug with double-quoted `.res` path.
2024-06-16 19:27:13 +02:00
Jeroen van Rijn fe3baae7a6 Merge pull request #3772 from Feoramund/fix-constant-wrong-type-bitset
Fix `bit_set` construction crash on constant non-integer field
2024-06-16 19:15:50 +02:00
Jeroen van Rijn eebc0dd026 Fix rc.exe bug with double-quoted .res path. 2024-06-16 19:11:54 +02:00
Feoramund 78a5a27212 Fix bit_set construction crash on constant non-integer field 2024-06-16 12:27:42 -04:00
Jeroen van Rijn 339bafe6ff Merge pull request #3770 from skaman/fix-slice-unique
Fix `slice.unique` wrong result
2024-06-16 13:48:21 +02:00
Jeroen van Rijn 0268be1925 Add tests for slice.unique and slice.unique_proc 2024-06-16 13:41:25 +02:00
Sandro Cavazzoni e41878a64f Fix slice.unique wrong result
When you try to make this array unique `[]int{1, 2, 4, 4, 5}` you get
`[]int{1, 4, 5}` instead of `[]int{1, 2, 4, 5}`.
Our index `i` should be increased even with both indices `i` and `j`
have the same value
2024-06-16 11:36:20 +02:00
Feoramund 8b31cddaba Keep -vet happy 2024-06-15 15:49:05 -04:00
Feoramund aab5338134 Add tests for core:math/rand 2024-06-15 15:49:05 -04:00
Feoramund 1a52cf1f1c Use test's random generator
This removes the `create` calls when a test was only setting up a
generator, and it replaces them with `reset` when run in a loop.
2024-06-15 15:49:05 -04:00
Feoramund 5dfd303fd1 Setup default context.random_generator for tests 2024-06-15 15:44:56 -04:00
gingerBill a619ea3bcd Merge pull request #3766 from Feoramund/fix-rng-state
Fix `default_random_generator_proc` not using state
2024-06-15 20:36:10 +01:00
ed fe4d6cbe5a Merge remote-tracking branch 'offical/master' 2024-06-15 15:00:21 -04:00
Feoramund 53140dca15 Fix default_random_generator_proc not using state 2024-06-15 12:54:30 -04:00
Jeroen van Rijn ed99e77433 Merge pull request #3765 from Feoramund/add-short-test-logs
Add `ODIN_TEST_SHORT_LOGS` define
2024-06-15 18:01:49 +02:00
gingerBill bacb915ff8 Merge branch 'master' of https://github.com/odin-lang/Odin 2024-06-15 16:24:07 +01:00
gingerBill e41ad2bf16 to_random_generator -> random_generator 2024-06-15 16:24:01 +01:00
gingerBill 4c7469a264 Merge pull request #3764 from Feoramund/test-runner-fixes
Fix half-implemented features in the test runner
2024-06-15 16:19:58 +01:00
Feoramund 753516c392 Add ODIN_TEST_SHORT_LOGS define
Strips out the procedure, date, and time information, for when you just
need to know the file, line, and message.
2024-06-15 11:18:40 -04:00
Feoramund f353adc7fb Prefer log.error over fail_now in this case 2024-06-15 10:53:21 -04:00
Feoramund bb823d5ba0 Make testing.fail_now divergent
This is in line with the old way it worked on Windows.
2024-06-15 10:53:21 -04:00
gingerBill 1c940e3968 Remove dead variable 2024-06-15 15:53:16 +01:00
gingerBill c97ffbecbc Fix rand in container tests 2024-06-15 15:50:35 +01:00
gingerBill 2380720fa2 Fix core:sync/chan for rand 2024-06-15 15:46:48 +01:00
Feoramund 784408358d Call cleanups after test signal 2024-06-15 10:46:47 -04:00
gingerBill 149ecafdef Remove the need for rand in core:math/big 2024-06-15 15:43:57 +01:00
gingerBill 7ec17ecf98 Update core:math/rand to use context.random_generator and remove rand.Rand 2024-06-15 15:33:24 +01:00
gingerBill 318d5e4a7e Add Reset mode 2024-06-15 15:17:23 +01:00
gingerBill eaec8a2bbf Add runtime.default_random_generator 2024-06-15 15:08:49 +01:00
gingerBill c2a01096c4 Remove unneeded reassignment of r 2024-06-15 14:49:09 +01:00
gingerBill 827cb24023 Add random_generator.odin 2024-06-15 14:47:37 +01:00
gingerBill dc4ec8638c Add runtime.Random_Generator interface 2024-06-15 14:45:57 +01:00
Jeroen van Rijn 94ec647923 Merge pull request #3750 from Kelimion/dcb_bitfield
Update kernel32 struct DCB.
2024-06-15 12:14:27 +02:00
Feoramund 51a013fcf1 Work around BSD lack of core:net support 2024-06-15 01:32:48 -04:00
Feoramund f28c6c3bba Keep -vet happy 2024-06-15 00:50:12 -04:00
Feoramund 53e2cdf7af Add core:flags to examples/all 2024-06-15 00:28:47 -04:00
Feoramund 76575e834b Raise error on spaced UNIX-style flag with no value 2024-06-15 00:24:59 -04:00
Feoramund 42a5a2cf17 Fix memory leak in core:flags validation 2024-06-15 00:01:33 -04:00
Feoramund c3acdeb310 Add -- parsing to UNIX-style core:flags
This will allow a user to indicate all arguments after `--` are parsed
into the variadic array.
2024-06-14 23:59:01 -04:00
Feoramund d4e2fa0377 Refactor show_error_on_line
This should adequately solve any issues with Unicode alignment by
sidestepping the issue entirely. With this change, we make use of the
built-in ANSI facilities of the terminal to underline the text.

If the terminal does not support underlining, there are still the
fallback bold markers at the start and end of error locations.
2024-06-14 18:28:47 -04:00
Feoramund 582154f20d Remove unused code from tokenizer 2024-06-14 15:44:50 -04:00
Jeroen van Rijn 908a6ff2d4 Elide unnecessary condition 2024-06-14 21:34:05 +02:00
Jeroen van Rijn 09b3f5a7a7 Merge pull request #3757 from thetarnav/patch-2
Add `#no_bounds_check` to `slice.equal`
2024-06-14 21:27:21 +02:00
Jeroen van Rijn fa4fbbe1ce Merge pull request #3758 from jones-josh/master
Fix big.shrink not actually shrinking
2024-06-14 20:27:03 +02:00
Josh Jones 759139089f Fix big.shrink not actually shrinking 2024-06-14 19:58:13 +02:00
Damian Tarnawski 8ba644dd79 Add #no_bounds_check to slice.equal 2024-06-14 19:45:54 +02:00
Feoramund 8626d38db1 Fix displaying emptiness when error is on first line 2024-06-14 13:02:54 -04:00
Jeroen van Rijn b19bf5bbda Merge pull request #3732 from FrancisTheCat/master
add missing functions to core:sys/windows
2024-06-14 17:57:23 +02:00
Feoramund ca481dc52d Fix displaying error on wrong line with token at EOL
Previously, this would get a token on text like "\n*\n" where `*`
is the token's position, and it would advance off that line.
2024-06-14 11:51:03 -04:00
Franz Höltermann c3302615a3 Merge branch 'master' of https://github.com/FrancisTheCat/Odin 2024-06-14 17:43:09 +02:00
Franz Höltermann 3c3f0f90c2 Fixed WinEventFlags 2024-06-14 17:41:21 +02:00
FrancisTheCat cd5fa8523f Merge branch 'odin-lang:master' into master 2024-06-14 16:34:21 +02:00
Franz Höltermann ec7b77fc0f Improved win32 bindings according to Kelimions suggestions with enums and bitsets 2024-06-14 16:32:41 +02:00
Matias Fernandez 4baf101f15 Handle empty structs in fmt with hash 2024-06-14 05:36:23 -04:00
Jeroen van Rijn ff4787070d Revert "Merge pull request #3744 from Mango0x45/master"
This reverts commit 45044de0b7, reversing
changes made to 20c17ba6f9.
2024-06-14 00:06:55 +02:00
Jeroen van Rijn 54a3cfb540 Merge pull request #3753 from Feoramund/fix-silent-token-fail
Fix compiler silently returning if `parse_packages` fails
2024-06-13 19:33:02 +02:00
Feoramund c560553c21 Fix compiler silently returning if parse_packages fails 2024-06-13 13:01:51 -04:00
Thomas la Cour acce9acb6d Merge remote-tracking branch 'upstream/master' into sys-windows-2 2024-06-13 18:31:53 +02:00
Jeroen van Rijn 45044de0b7 Merge pull request #3744 from Mango0x45/master
Pad ‘^~~~^’-style diagnostic ranges properly
2024-06-13 17:34:17 +02:00
Jeroen van Rijn c9c7d3270d Merge branch 'master' of https://github.com/Mango0x45/Odin into pr/3744 2024-06-13 17:27:00 +02:00
Thomas Voss 9f7ac1469f Generate ranges of the correct length 2024-06-13 17:24:56 +02:00
Jeroen van Rijn ca9d1f940d Just change squiggle_extra type to i32. 2024-06-13 17:23:30 +02:00
Thomas Voss 9f190f3937 Generate ranges of the correct length 2024-06-13 17:00:13 +02:00
Thomas Voss 657c516360 Pad ‘^~~~^’-style diagnostic ranges properly 2024-06-13 16:23:34 +02:00
Jeroen van Rijn 20c17ba6f9 Merge pull request #3751 from Kelimion/custom_formatter
Add example of a custom formatter.
2024-06-13 11:42:38 +02:00
Jeroen van Rijn 3d4e23d741 Add example of a custom formatter. 2024-06-13 11:33:37 +02:00
Jeroen van Rijn 50564a301e Update kernel32 struct DCB. 2024-06-13 10:22:44 +02:00
Jeroen van Rijn f8f6f2dada Merge pull request #3749 from Feoramund/fix-w
Improve support for `%w`
2024-06-13 10:07:48 +02:00
korvahkh 104ca2ce22 Merge branch 'odin-lang:master' into fix-omitempty-comma 2024-06-13 01:27:44 +00:00
Feoramund abe5c2ca83 Add test for %w 2024-06-12 21:07:15 -04:00
Feoramund 0c9f487783 Fix and document %w verb for core:fmt 2024-06-12 20:35:50 -04:00
gingerBill a67df07392 Merge pull request #3742 from karl-zylinski/fix-raymath-matrix-to-float
Make rl.MatrixToFloatV do same thing in Odin as in C
2024-06-12 23:15:48 +01:00
Jeroen van Rijn 05972eb26b Merge pull request #3746 from jasonKercher/add-commtimeouts
add COMMTIMEOUTS, get/setCommTimeouts
2024-06-12 21:50:10 +02:00
gingerBill 4ccc473e97 Merge pull request #3745 from karl-zylinski/rlgl-add-missing-types
rlgl: Pull in raylib and expose missing types
2024-06-12 20:48:22 +01:00
gingerBill 90815452ca Merge pull request #3747 from Feoramund/fix-3739
Fix #3739
2024-06-12 20:48:02 +01:00
jasonkercher a804463a57 add COMMTIMEOUTS, get/setCommTimeouts 2024-06-12 15:31:59 -04:00
Feoramund 33270f14a4 Fix #3739 2024-06-12 15:31:43 -04:00
Karl Zylinski c7ea4ec71c rlgl: Pull in raylib and expose missing types, so it is the same as rlgl.h. This makes rlgl less stand-alone, but I left some notes in rlgl.odin how to easily make it stand-alone if one really wants to. 2024-06-12 21:13:12 +02:00
Karl Zylinski d37b5a7b67 Make rl.MatrixToFloatV transpose the matrix before transmuting it to [16]f32, so it does the same thing as the raymath version implemented in C. 2024-06-12 19:54:14 +02:00
Feoramund 1128bd1d7f Use syscall_bsd on NetBSD 2024-06-12 13:34:36 -04:00
Feoramund 20c32c807d Fix info.init_os_version on FreeBSD
It's possible for the return string to be longer than 128 characters
these days, so I've increased it to 1024, same as the other BSDs.

SYSCTL was otherwise erring out due to lack of buffer space.
2024-06-12 13:10:19 -04:00
Feoramund 5b5402fb23 Add intrinsics.syscall_bsd
This is a BSD-style syscall that checks for a high Carry Flag as the
error state. If the CF is high, the boolean return value is false, and
if it is low (no errors) then the boolean return value is true.
2024-06-12 13:07:13 -04:00
Laytan Laats 108b8feb35 Add vendor:wgpu 2024-06-12 17:22:02 +02:00
Jeroen van Rijn 603581aa53 Merge pull request #3738 from Kelimion/xml_attr
Xml attr
2024-06-12 14:06:40 +02:00
gingerBill c5f7788652 Check to see if matrices are exactly the same type 2024-06-12 12:54:57 +01:00
gingerBill f57c03c170 Improve matrix type hinting rules a little 2024-06-12 12:40:29 +01:00
Jeroen van Rijn 2fe961cbcd Fold XML attribute whitespace. 2024-06-12 13:30:00 +02:00
Jeroen van Rijn ebadff555d Update XML reader to normalize whitespace, part 1. 2024-06-12 12:52:48 +02:00
gingerBill cb45aa58fd Merge pull request #3731 from karl-zylinski/rlgl-subpackage
Move rlgl to vendor:raylib/rlgl
2024-06-12 11:51:16 +01:00
ed b7a7ada7ae Update ast_kinds.hpp to latest changes 2024-06-11 19:26:26 -04:00
ed 3f0169d9ff Merge remote-tracking branch 'offical/master' 2024-06-11 19:23:35 -04:00
gingerBill e87c5bca58 Merge pull request #3737 from karl-zylinski/raylib-shader-location-index-any-int
Made rl.SetShaderValue etc take a c.int like in original raylib
2024-06-11 21:45:40 +01:00
Jeroen van Rijn 0398388a59 Merge pull request #3729 from Feoramund/fix-3460
Fix #3460
2024-06-11 20:32:37 +02:00
Thomas la Cour 8403952fd2 win32gen 2024-06-11 18:30:41 +02:00
Thomas la Cour 32dcb3caef windows bindings test 2024-06-11 18:19:29 +02:00
Thomas la Cour 465ac74020 more windows stuff 2024-06-11 18:19:16 +02:00
Karl Zylinski 1a22f82f94 Changed rl.SetShaderValue etc to take a c.int like in original raylib.h. You should be able to use other values than the ShaderLocationIndex enum, that enum is only for build in things in raylib. Added #any_int on those procs so you can pass both int and also a ShaderLocationIndex. 2024-06-11 18:03:20 +02:00
gingerBill 35a845b93f Fix indentation 2024-06-11 13:12:41 +01:00
gingerBill 3ff8952813 Replace panic(fmt.tprintf( antipattern with fmt.panicf 2024-06-11 13:11:14 +01:00
gingerBill 56c5e93fd1 Merge pull request #3728 from Feoramund/mem-any-int
Use `#any_int` for `reserve_*` and `resize_*` procs
2024-06-11 12:52:50 +01:00
gingerBill 39b166edd3 Merge pull request #3733 from Feoramund/ci-freebsd
Add FreeBSD to the CI
2024-06-11 12:51:42 +01:00
gingerBill eaf1d88287 Merge pull request #3734 from Feoramund/fix-3730
Fix #3730
2024-06-11 12:50:41 +01:00
gingerBill 1dc90103bd Make verification ignorable with a define flag 2024-06-11 12:30:24 +01:00
gingerBill 0b02c67cdf Minor clean up for backend 2024-06-11 12:19:52 +01:00
gingerBill 9b0e87544a Unify LLVMVerifyFunction invocations into on place 2024-06-11 12:07:22 +01:00
Feoramund 61c630bbf8 Fix #3730 2024-06-11 05:23:43 -04:00
Feoramund 0e6bcd0dbb Add FreeBSD to CI 2024-06-11 04:16:42 -04:00
Feoramund fc88de12c2 Implement absolute_path_from_handle for FreeBSD 2024-06-11 04:16:42 -04:00
Feoramund a3da796d54 Fix file_size on FreeBSD
It was using the generic UNIX `fstat` implemented in Odin, which is more
than what is needed here.

This also avoids the issue of needing a proper
`absolute_path_from_handle` implementation for it to work without error.
2024-06-11 03:55:41 -04:00
Feoramund 40e99ebb10 Fix file open O_* flags on FreeBSD 2024-06-11 03:55:41 -04:00
Feoramund c68560c573 Use correct __error link name for FreeBSD 2024-06-11 03:55:41 -04:00
Feoramund 76292c8ed5 Forbid all BSDs from running core:net tests
`net` is not yet implemented on them.
2024-06-11 03:55:41 -04:00
Franz Höltermann c6c00c706a Merge branch 'master' of https://github.com/odin-lang/Odin 2024-06-11 09:37:20 +02:00
Franz Höltermann 6454c6f087 Added some missing functions to core/sys/windows 2024-06-11 09:35:59 +02:00
Karl Zylinski c9e732d141 rlgl.RLGL_VERSION -> rlgl.VERSION 2024-06-11 08:59:30 +02:00
Karl Zylinski d2cd96c3c8 Made rlgl.odin work as a subpackage of raylib. So now you import vendor:raylib/rlgl. Instead of rl.rlBegin(rl.RL_TRIANGLES) you now type rlgl.Begin(rlgl.TRIANGLES). 2024-06-11 08:46:44 +02:00
Karl Zylinski 34af2bb8ad Moved rlgl.odin to subpackage 'raylib/rlgl' 2024-06-11 08:34:45 +02:00
Feoramund bd198aeada Fix #3460 2024-06-10 23:37:54 -04:00
Feoramund 50464bdce3 Use #any_int for reserve_* and resize_* procs
Resolves #3088
2024-06-10 20:51:58 -04:00
gingerBill f1779c85de Fix #3727 2024-06-10 18:50:53 +01:00
gingerBill 903e254e36 Merge pull request #3725 from laytan/add-forced-shutdown-to-test-runner
add forced shutdown to new test runner
2024-06-10 15:08:09 +01:00
gingerBill eef2aef021 Fix #3724 2024-06-10 15:07:45 +01:00
gingerBill c1e81dc14d Fix #3726 2024-06-10 15:05:24 +01:00
gingerBill fa3cae2bb0 Add intrinsics.procedure_of
```odin
foo :: proc(x: $T) { fmt.println(x) }
bar :: intrinsics.procedure_of(foo(int(123))) // parameters are never ran at compile time, similar to `size_of`
bar(333) // prints 333
```
2024-06-10 15:02:34 +01:00
Laytan Laats 71929f737b add forced shutdown to new test runner
Currently, a Ctrl+c starts a graceful shutdown of the tests and runner.
Sometimes tests get stuck and this would never complete.

This simply adds an extra step, if Ctrl+c is given for the second time,
just `os.exit` right away.
2024-06-10 15:35:23 +02:00
gingerBill 1945218f6d Improve parsing for label: #reverse for and label: #partial switch 2024-06-10 14:18:33 +01:00
Jeroen van Rijn bedeaa34d9 Merge pull request #3723 from Feoramund/use-final-march
Use `get_final_microarchitecture()` for `ODIN_MICROARCH_STRING`
2024-06-10 11:40:01 +02:00
Feoramund 71a812e7fe Use get_final_microarchitecture() for ODIN_MICROARCH_STRING 2024-06-10 05:30:16 -04:00
Jeroen van Rijn 741ee00b64 Merge pull request #3721 from Feoramund/add-tuning-consts
Add compilation-related constants
2024-06-10 10:31:12 +02:00
Jeroen van Rijn d3ae70264e Merge pull request #3720 from Feoramund/fix-force-inline-err-typo
Fix typo in a `#force_inline` error message
2024-06-10 10:25:09 +02:00
Jeroen van Rijn c8b376f07f Merge pull request #3719 from Feoramund/fix-orbranch-error
Fix `or_or_<branch>` error message
2024-06-10 10:21:05 +02:00
Feoramund ff7fcb6d38 Add compilation-related constants
`ODIN_VERSION_HASH` is the `git` SHA hash of the commit the Odin
compiler was built with.

`ODIN_MICROARCH_STRING` is the string passed to `-microarch` when
the program was built.

`ODIN_OPTIMIZATION_MODE` is an enum value of which optimization mode was
used to build the program.
2024-06-10 03:47:20 -04:00
Feoramund 45d1328a85 Fix typo in a #force_inline error message 2024-06-10 00:50:16 -04:00
Feoramund 8702bf00d5 Remove _ in Syntax_Error verbose message 2024-06-09 22:47:43 -04:00
Feoramund 9d28f2e18c Fix or_or_<branch> error messages 2024-06-09 22:46:45 -04:00
ed db610c4639 Merge remote-tracking branch 'offical/master' 2024-06-09 22:25:45 -04:00
Jeroen van Rijn 5985c6e3df Merge pull request #3718 from Feoramund/add-missing-big-atoi-alias
Add missing `string_to_int` alias in `core:math/big`
2024-06-10 03:58:56 +02:00
Jeroen van Rijn 82e2d1916f Merge pull request #3717 from Feoramund/big-combo
Add permutation & combination procs to `core:math/big`
2024-06-10 03:47:55 +02:00
Feoramund 70820c2c40 Add missing string_to_int alias in core:math/big 2024-06-09 21:42:31 -04:00
Feoramund fe5c278fca Add test for core:math/big permutation & combination procs 2024-06-09 20:42:09 -04:00
Feoramund f0d65112b8 Rename math/big test package
This is in line with the other tests, and it does not seem to affect
building the library.
2024-06-09 20:42:07 -04:00
Feoramund 5fbd876db1 Add permutation & combination procedures to core:math/big 2024-06-09 20:42:04 -04:00
Jeroen van Rijn 4ea593bde0 Merge pull request #3716 from Feoramund/slice-permute
Add in-place permutation iterator to `core:slice`
2024-06-09 22:42:43 +02:00
Feoramund 047b505836 Add test for slice.permute 2024-06-09 16:15:43 -04:00
Feoramund 1f64d8d5bd Add slice.permute 2024-06-09 16:15:41 -04:00
gingerBill 7c529e990d Add -target:freestanding_arm32 (experimental) 2024-06-09 17:48:46 +01:00
gingerBill 828870004b Change indentation 2024-06-09 17:15:08 +01:00
Jeroen van Rijn 7e60e21934 Merge pull request #3714 from Kelimion/png_cleanup
PNG cleanup
2024-06-09 18:09:17 +02:00
Jeroen van Rijn 5be7d8e32d Clean up PNG code. 2024-06-09 17:59:59 +02:00
Jeroen van Rijn fc2ba81be0 Merge branch 'master' into png_cleanup 2024-06-09 17:13:43 +02:00
gingerBill edcbca51c3 Merge pull request #3684 from odin-lang/tlsf-allocator
`core:mem/tlsf` - "Two-Level Segregated Fit" memory allocator
2024-06-09 15:54:46 +01:00
Jeroen van Rijn 3c7e2659ac Merge branch 'master' into tlsf-allocator 2024-06-09 16:42:23 +02:00
Jeroen van Rijn 6b88d0a820 Use new blend helper 2024-06-09 16:37:27 +02:00
Jeroen van Rijn d2a2c1e74e Image: Add improved blending method and test it. 2024-06-09 16:10:06 +02:00
gingerBill ef7c6b9895 Re Fix #3713 2024-06-09 14:07:07 +01:00
gingerBill c17981ac38 Add edge case to error_operand_no_value 2024-06-09 14:02:01 +01:00
gingerBill 4b52f7fe2b Fix #3713 2024-06-09 13:35:22 +01:00
gingerBill 8fcfd8c506 Fix sign flag 2024-06-09 13:21:22 +01:00
gingerBill e0d0dc704c Make f32(u8) etc do an immediate cast to f32(u32(u8)) in code generation 2024-06-09 13:20:48 +01:00
Jeroen van Rijn 14f08ff02b Merge pull request #3712 from laytan/fix-large-ints-amd64sysv-abi
fix large ints amd64 sysv abi
2024-06-09 11:01:31 +02:00
Jeroen van Rijn 5d5ef78de9 Merge pull request #3711 from laytan/fix-swizzle-crash
fix swizzle crash due to wrong alignment
2024-06-09 11:00:15 +02:00
Jeroen van Rijn e595bdc805 Merge pull request #3710 from laytan/fix-unreachable-with-complex-param-or-return-inits
fix unreachable hit when param and/or return have complex inits
2024-06-09 10:59:26 +02:00
Laytan Laats 6d862cc4e5 fix unreachable hit when param and/or return have complex inits
Fixes #3630
2024-06-09 04:43:19 +02:00
Laytan Laats 3628154849 fix swizzle crash due to wrong alignment
Fixes #3691
2024-06-09 03:33:23 +02:00
Laytan Laats 9ad9236c3b fix large ints amd64 sysv abi
Fixes #3707
2024-06-09 02:47:05 +02:00
Jeroen van Rijn 0d698c7b53 Merge pull request #3709 from Feoramund/stop-low-swizzle
Prevent panic when `swizzle` called with < 2 indices
2024-06-08 23:14:55 +02:00
Feoramund 49f147cc86 Prevent panic when swizzle called with < 2 indices
The requirement for at least 2 indices has been sourced from
`lb_addr_swizzle` in `llvm_backend_general.cpp`, where there is an
assert to ensure the swizzle_count is `1 < n <= 4`.
2024-06-08 17:05:00 -04:00
Jeroen van Rijn e5bf6fd3aa Merge pull request #3708 from Feoramund/ignore-bmp-assets
Add `*.bmp` to core tests `.gitignore`
2024-06-08 22:45:08 +02:00
Feoramund 5c8f78a25a Add *.bmp to core tests .gitignore 2024-06-08 16:43:45 -04:00
Jeroen van Rijn 1f4cfd52fd Merge pull request #3706 from leidegre/os_read_dir_windows
Fixed error handling in read_dir on Windows
2024-06-08 17:14:49 +02:00
gingerBill be0774acc8 Add error message on return a constant slice value from a procedure 2024-06-08 16:07:28 +01:00
Jeroen van Rijn de7d3e2487 Update dir_windows.odin 2024-06-08 17:00:38 +02:00
gingerBill 7e994b6d21 Remove empty line preventing a suggestion from happening 2024-06-08 15:42:19 +01:00
John Leidegren 35e57fdef8 Fixed error handling in read_dir on Windows 2024-06-08 15:58:34 +02:00
gingerBill 371749d474 Make certain procedures "contextless" for microui 2024-06-08 14:48:04 +01:00
Jeroen van Rijn 575e5a255b Merge pull request #3704 from Feoramund/fix-fmt-p-verb
Fix `%p` pointers not printing leading `0x`
2024-06-07 23:00:29 +02:00
Jeroen van Rijn 323a6e0728 Nuke ancient comment. 2024-06-07 22:19:01 +02:00
Feoramund affd48c791 Add #caller_location to check in fmt tests
This makes it much easier to track down which line failed.
2024-06-07 16:08:37 -04:00
Feoramund b65589d036 Add %p tests for fmt 2024-06-07 16:07:11 -04:00
Feoramund 61c481bd81 Fix %p pointers not printing leading 0x 2024-06-07 15:27:43 -04:00
Jeroen van Rijn 96c06185dd Merge pull request #3701 from laytan/fix-thread-deadlock
Fix thread deadlock
2024-06-07 20:39:40 +02:00
Laytan Laats 00dfff7ee0 core/thread: fix a deadlock situation on unix 2024-06-07 20:28:09 +02:00
Laytan Laats b35e72c82b core/sync: fix wrong timeout calculation, time.Duration is ns already 2024-06-07 20:27:33 +02:00
Feoramund edb685f04b Add package core:flags 2024-06-07 13:16:13 -04:00
Jeroen van Rijn 7c977bb859 Merge pull request #3699 from laytan/macos-14.5
add MacOS 14.5 to 'core:sys/info' and 'odin report'
2024-06-07 17:44:09 +02:00
Laytan Laats 072825ac5a add MacOS 14.5 to 'core:sys/info' and 'odin report' 2024-06-07 17:42:41 +02:00
Jeroen van Rijn 4c45f7d3ae Merge pull request #3698 from laytan/utilize-odin-test-instead-of-scrips-to-run-tests
Utilise `odin test` instead of scripts to run tests
2024-06-07 17:36:23 +02:00
Jeroen van Rijn 11137cfec5 Merge pull request #3697 from laytan/add-error-message-for-unknown-test-log-level
add error message for unknown test log level
2024-06-07 17:11:48 +02:00
Laytan Laats e627fcb0e6 fix not printing Error: when terminal has no color support 2024-06-07 16:58:23 +02:00
Laytan Laats 29250f2657 fix regression in test_issue_2395 2024-06-07 16:33:38 +02:00
Laytan Laats 9122c20d4b update actions/checkout 2024-06-07 15:57:09 +02:00
Laytan Laats 0a528777e8 utilize odin test -all-packages instead of (make/bat) scripts for running tests 2024-06-07 15:50:00 +02:00
Laytan Laats f2be35f1f0 remove caught unused define 2024-06-07 15:22:14 +02:00
Laytan Laats ee93d7c05e add error message for unknown test log level
It would previously just be a compilation error about a missing
return statement.
2024-06-07 15:13:09 +02:00
Laytan Laats 315695b4f8 collect and show docs of defineables 2024-06-07 15:08:41 +02:00
gingerBill 68781f8dd3 Remove unnecessary Wait_Signal checks 2024-06-07 00:11:00 +01:00
gingerBill 1d99bc0f87 Merge branch 'master' of https://github.com/odin-lang/Odin 2024-06-06 23:55:54 +01:00
gingerBill 7044a7d776 Try to fix a possible race condition with polymorphic record parameters 2024-06-06 23:55:48 +01:00
Jeroen van Rijn 4b6fe2baa7 Merge pull request #3696 from Kelimion/bmp_save
BMP save
2024-06-07 00:23:55 +02:00
Jeroen van Rijn ed060819f3 Test roundtripping BMP 2024-06-07 00:14:15 +02:00
Jeroen van Rijn 566119ff83 Add saving of 24 and 32-bit images to BMP format. 2024-06-06 23:53:15 +02:00
gingerBill 08612423b9 Merge branch 'master' of https://github.com/odin-lang/Odin 2024-06-06 21:03:44 +01:00
gingerBill ff37a7435c Add parentheses around the foreign import paths 2024-06-06 21:03:35 +01:00
Laytan Laats fa08690686 explicit integer conversions 2024-06-06 19:49:51 +02:00
Laytan Laats b818a77131 check if -define is actually used 2024-06-06 19:46:01 +02:00
Laytan Laats 9a95049393 -show-defineables and -export-defineables 2024-06-06 19:44:54 +02:00
Jeroen van Rijn b196b84ef2 Merge pull request #3695 from laytan/fix-linking-on-weird-linuxes
fix linking on weird linuxes
2024-06-06 19:37:31 +02:00
Laytan e2eb3cdd8a fix linking on weird linuxes 2024-06-06 19:23:36 +02:00
gingerBill d0dbe9a1bd Merge branch 'master' of https://github.com/odin-lang/Odin 2024-06-06 17:59:19 +01:00
gingerBill 039bb8794a Improve matrix_align_of logic when it has invalid inputs. 2024-06-06 17:59:12 +01:00
gingerBill f010544eff Merge pull request #3609 from Kelimion/bmp
Add core:image/bmp
2024-06-06 16:29:35 +01:00
Jeroen van Rijn 4a290f47ad Re-add BMP test suite download. 2024-06-06 16:55:03 +02:00
Jeroen van Rijn 678fdae966 Rebased. 2024-06-06 16:32:18 +02:00
ed 8bfc2a0af0 Merge remote-tracking branch 'offical/master' 2024-06-06 10:31:33 -04:00
gingerBill 3a9b86628a Add @(rodata) and @(static, rodata) where appropriate 2024-06-06 15:23:52 +01:00
gingerBill bea47db495 Allow @(rodata) on @(static) variables 2024-06-06 15:20:47 +01:00
gingerBill 9ef43fc782 Add @(rodata) 2024-06-06 15:16:34 +01:00
Jeroen van Rijn 28ea9425fd Add core:mem tests. 2024-06-06 14:59:19 +02:00
Jeroen van Rijn 72f6b5479d Fix fls_uint 2024-06-06 14:42:19 +02:00
Jeroen van Rijn 0b6d73c86e Add original LICENSE 2024-06-06 14:29:28 +02:00
gingerBill 971229fe66 Fix #3686 2024-06-06 13:27:55 +01:00
gingerBill c4ef8e7f6c Merge branch 'master' of https://github.com/odin-lang/Odin 2024-06-06 13:02:16 +01:00
gingerBill 155516b897 Fix -ignore-warnings 2024-06-06 13:02:08 +01:00
Jeroen van Rijn 9b66b0c8e6 Merge pull request #3694 from rope-hmg/master
Updated SDL_CreateTexture to take `PixelFormatEnum` instead of `u32`
2024-06-06 13:03:16 +02:00
Hector 483015fe57 Updated SDL_CreateTexture to take PixelFormatEnum instead of u32 2024-06-06 11:47:59 +01:00
gingerBill a73741d3b7 Merge pull request #3690 from laytan/orcas
Runtime support for orca
2024-06-06 11:03:51 +01:00
Jeroen van Rijn fb2849e02e Merge pull request #3693 from colrdavidson/x11-title-change-support
Add support functions for title changes, cursor config, and dnd
2024-06-06 11:48:16 +02:00
Colin Davidson 70592630a4 add support for title changes, cursor config, and dnd 2024-06-06 02:39:48 -07:00
Jeroen van Rijn fcfc1cb97f Nightly ZIP level 9 2024-06-05 22:26:03 +02:00
Jeroen van Rijn cdd90a9a0b Merge pull request #3688 from Kelimion/nightly
Rewrite upload_b2 nightly action against B2 SDK
2024-06-05 21:11:25 +02:00
Jeroen van Rijn 460ffe1aee Rewrite upload_b2 nightly action against B2 SDK 2024-06-05 21:04:35 +02:00
laytan 08382cb05d orca windows 2024-06-05 19:28:40 +02:00
Laytan Laats 8455e159f5 improve orca target 2024-06-05 20:57:39 +02:00
gingerBill 76d3be7912 Merge pull request #3683 from andreas-jonsson/test-make-cleanup
Minor cleanup of makefiles and scripts
2024-06-05 15:44:27 +01:00
gingerBill 97f0f72080 Merge pull request #3685 from markersniffen/sniffen
D3D11.odin - fix VIDEO_SUPPORT flag
2024-06-05 15:43:55 +01:00
gingerBill a667878d23 Merge branch 'master' of https://github.com/odin-lang/Odin 2024-06-05 15:43:21 +01:00
gingerBill cbabcb0907 Fix #3682 2024-06-05 15:43:15 +01:00
gingerBill fac9ce5d83 Change to init from create 2024-06-05 15:30:35 +01:00
gingerBill d3342c2381 core:mem/tlsf - "Two-Level Segregated Fit" memory allocator 2024-06-05 15:15:39 +01:00
Mark Sniffen cd4375061c D3D11 - fixed VIDEO_SUPPORT flag 2024-06-05 10:11:18 -04:00
Andreas T Jonsson f0e98372fb Minor cleanup of makefiles and scripts 2024-06-05 15:37:02 +02:00
gingerBill a747e47582 Merge pull request #3675 from Feoramund/fix-partial-infinity
Fix partial parsing of `infinity`
2024-06-05 12:48:44 +01:00
gingerBill adcda88501 Merge pull request #3680 from andreas-jonsson/netbsd-arm64
ARM64 support for NetBSD
2024-06-05 12:47:29 +01:00
gingerBill e7190aab41 Merge pull request #3681 from andreas-jonsson/netbsd-lwp-self
Proper thread identification on NetBSD
2024-06-05 12:47:23 +01:00
Andreas T Jonsson 929437c7bc Fixed broken import 2024-06-05 11:17:13 +02:00
Andreas T Jonsson ed6667ebf2 Propper thread identification on NetBSD 2024-06-05 11:06:14 +02:00
Andreas T Jonsson 58f07698e8 Added arm64 support for NetBSD 2024-06-05 10:18:47 +02:00
Jeroen van Rijn c406bbb6e3 Merge pull request #3679 from Feoramund/fix-typos
Fix some typos
2024-06-05 09:30:10 +02:00
Feoramund b2f9f0af68 Fix some typos 2024-06-04 19:01:30 -04:00
Feoramund 25feff3eb4 Permit parsing of incomplete infinity but do not return true
To clarify, `parse_f64` will indeed take `infi` to mean `+Inf` and
return that as the value, but it will not return `ok = true`. It treats
it as `inf` followed by any other trailing character.

`parse_f64_prefix` is the lenient one which will return true so long as
it finds some meaningful value.
2024-06-04 18:55:13 -04:00
Feoramund 1fc6ff91b2 Add test for infinity with trailing characters 2024-06-04 18:55:13 -04:00
gingerBill 2c580aa6fb Merge pull request #3676 from laytan/fix-passing-pointer-to-constant-to-non-odin-cc
fix passing pointer to constant in non-odin cc
2024-06-04 23:12:46 +01:00
Jeroen van Rijn f0a6fb4057 Merge pull request #3678 from Feoramund/fix-p-f64-p-doc
Strike incorrect note from `parse_f64_prefix` doc
2024-06-05 00:02:34 +02:00
Jeroen van Rijn 448c0d8dd3 Merge pull request #3677 from Feoramund/parse-compquat
Add `parse_complex/quaternion*` to `core:strconv`
2024-06-04 23:58:43 +02:00
Feoramund b4cfae222c Strike incorrect note from parse_f64_prefix doc 2024-06-04 17:50:19 -04:00
Feoramund 265e6aa781 Add parse_complex/quaternion* to core:strconv 2024-06-04 17:12:55 -04:00
Jeroen van Rijn 9d234998c0 Update create_nightly_json 2024-06-04 22:44:49 +02:00
Jeroen van Rijn c2ddf4266f Update delete_old_binaries.py 2024-06-04 22:26:51 +02:00
gingerBill a0b1b8d1c3 Merge pull request #3673 from laytan/implement-foreign-import-improvements-on-vendor
Implement `#exists(path)` and use it to provide good errors for common missing vendor libraries
2024-06-04 19:57:09 +01:00
Laytan Laats dbaf1a1ce0 compile stb_vorbis 2024-06-04 20:26:21 +02:00
Feoramund c656a9e4cd Fix and subsume test_issue_2087 into strconv test suite
The full "infinity" strings were expected to be partial consumes, but
this is not the case. That has been fixed and the relevant extra tests
from that file have been added to this test suite.

Fixes #2670
2024-06-04 14:23:48 -04:00
Laytan Laats cd99625dd3 ci: compile needed libraries 2024-06-04 20:21:52 +02:00
Feoramund 7d670f6562 Add initial test suite for core:strconv 2024-06-04 14:20:31 -04:00
laytan 2a526058b3 fix passing pointer to constant in non-odin cc 2024-06-04 20:15:47 +02:00
Laytan Laats 3e159736cd use #exists to provide good errors for common missing libraries 2024-06-04 20:13:51 +02:00
Feoramund d33668fa91 Fix partial parsing of "infinity" in parse_f64_prefix
It was previously reporting an invalid number of characters parsed for
any string other than "inf", "+inf", or "-inf".
2024-06-04 13:24:46 -04:00
Laytan Laats b47a15733d implement #exists(path) 2024-06-04 19:06:13 +02:00
Laytan Laats 4f5b2bd127 fix crash when you have 2 #load_directory calls with the same path 2024-06-04 19:01:50 +02:00
gingerBill 3b7100f8e5 raygui: change c.int to their correct enum types 2024-06-04 16:17:49 +01:00
gingerBill 6b386631dd Improve error message suggestion for passing enums to integers 2024-06-04 16:16:27 +01:00
gingerBill 11b1a48bf0 Fix extra_linker_flags for raylib on windows 2024-06-04 15:54:57 +01:00
gingerBill 72ce111a95 Keep -vet happy 2024-06-04 15:51:19 +01:00
gingerBill 606608c02b Utilize foreign import constant strings for foreign imports 2024-06-04 15:49:17 +01:00
gingerBill eacf2918ad Merge pull request #3469 from hodgka/raylib_resizable_doc_patch
Fixed typo in raylib documentation
2024-06-04 15:41:15 +01:00
gingerBill afcccfdec5 Merge pull request #3615 from puzzleddev/export-dependencies
Add build flag to export dependencies.
2024-06-04 15:40:54 +01:00
gingerBill 60a064984d Merge pull request #3670 from colrdavidson/x11-tweaks
Correct X11 prefix issues
2024-06-04 15:02:03 +01:00
gingerBill 0504c12f04 Merge pull request #3672 from laytan/fix-old-llvm-debug-info
fix debug info IR error on LLVM < 13
2024-06-04 15:01:30 +01:00
Laytan Laats 7d29389834 fix debug info IR error on LLVM < 13 2024-06-04 14:41:42 +02:00
Colin Davidson 52ba3357ee oops, missed shuffling a few x-funcs 2024-06-04 04:48:24 -07:00
Jeroen van Rijn 78a67ef31e Merge pull request #3667 from Feoramund/fix-fmt-compquat-sign
Fix printing of duplicate signs in complex and quaternion types
2024-06-04 13:32:13 +02:00
Jeroen van Rijn f9d59ef6d4 Merge branch 'master' into fix-fmt-compquat-sign 2024-06-04 13:25:57 +02:00
Jeroen van Rijn c3b94b9e1d Merge pull request #3646 from Feoramund/multi-test
Refactor the test runner
2024-06-04 13:23:52 +02:00
Feoramund eb93779f63 Fix duplicate sign printing of complex and quaternion types
Negative zero wasn't being detected (so it would appear as `+-0`), and
`+Inf` was appearing as `++Inf` when imaginary.
2024-06-03 19:51:17 -04:00
Feoramund d2a9122176 Add fmt tests for printing complex and quaternion types 2024-06-03 19:48:09 -04:00
Feoramund 0ff130d82b Fix ad hoc printf in test runner signal handler 2024-06-02 23:36:04 -04:00
Feoramund fa29974dab Use Warning log level for reporting memory leaks
Works well with `-define:ODIN_TEST_LOG_LEVEL=warning`.
2024-06-02 23:21:44 -04:00
Feoramund 7764ab2ab0 Prevent test runner deadlock on NetBSD
Add `pthread_testcancel` to `core:sys/unix`
2024-06-02 21:27:36 -04:00
Feoramund 6a5633df2d Fix wrong PTHREAD_CANCEL_ASYNCHRONOUS on FreeBSD and OpenBSD
The test runner was deadlocking when a test raised a signal on FreeBSD.

This is untested on OpenBSD, but I have referenced this file:
https://github.com/openbsd/src/blob/master/include/pthread.h
2024-06-02 20:41:25 -04:00
Feoramund c8539fe411 Revert "Disable NetBSD tests until 'undefined reference to stdout' is solved."
This reverts commit 21a1ddfbae.
2024-06-02 19:29:27 -04:00
Feoramund ac9484206b Fix STDIN, STDOUT, STDERR handles for BSDs
Tested on FreeBSD 14.0 and NetBSD 10.0

OpenBSD is untested, but link names were sourced from:
https://github.com/openbsd/src/blob/master/include/stdio.h

According to this, OpenBSD shares the same layout as NetBSD.

FreeBSD has the same as Darwin in this regard.
2024-06-02 19:29:27 -04:00
Feoramund f77ce359ce Be pedantic about not overwriting Odin errors
I was encountering bounds-check error messages being overwritten during
a test, if the test failed for another reason and sent a log message.

The original intent of having this check inside of the above `if` block
was that if a test sent an error message, then it was assumed an
overwrite would be safe, but it's completely possible for a test to fail
for a legitimate reason, then do an unrelated bounds check somewhere
else that would be buried under the animation.

This change will make sure that, no matter what, the progress display
will not trigger a clear if a signal was raised. There's still no
guarantee that bounds-check messages will be printed properly, and it's
best to redirect STDERR.

The only way that can be fixed is if they get a similar hook to
`context.assertion_failure_proc`.
2024-06-02 15:51:26 -04:00
Feoramund 3f1249c27e Tell user about ODIN_TEST_RANDOM_SEED option 2024-06-02 15:34:13 -04:00
Feoramund 8d8c42e962 Use T.seed in tests where applicable 2024-06-02 15:30:23 -04:00
Jeroen van Rijn 60d0c03134 Strip old test runner back out of internal, issues and vendor 2024-06-02 21:15:25 +02:00
Jeroen van Rijn 9d8d864400 Plug leak in AES tests. 2024-06-02 21:12:24 +02:00
Jeroen van Rijn 21a1ddfbae Disable NetBSD tests until 'undefined reference to stdout' is solved. 2024-06-02 21:03:22 +02:00
Feoramund 890fe07c6e Disable FANCY_OUTPUT in Odin test scripts
This should tidy up the CI output logs a bit.
2024-06-02 14:54:32 -04:00
Feoramund d581dbbec5 Keep test runner main thread from using 100% of a CPU core 2024-06-02 14:54:32 -04:00
Feoramund 5e3e958574 Add -define:ODIN_TEST_LOG_LEVEL to set lowest log level 2024-06-02 14:54:32 -04:00
Feoramund 6a9203328b Log thread count at test run start
Provides a helpful info message about the option to change how many
threads are used per run.
2024-06-02 14:54:32 -04:00
Feoramund 5db65aa796 Make it easier to learn about ODIN_TEST_CLIPBOARD 2024-06-02 14:54:32 -04:00
Feoramund cb00b8022b Add note about SIGSEGV edge case on UNIX-likes 2024-06-02 14:54:32 -04:00
Feoramund 4875f745c8 Remove Windows test runner in favor of libc implementation 2024-06-02 14:54:32 -04:00
Feoramund ccdbd4b6ce Simplify casts in mem.Rollback_Stack procs 2024-06-02 14:54:32 -04:00
Feoramund 9dcf345795 Set thread pool is_running to false on shutdown 2024-06-02 14:54:32 -04:00
Feoramund 21064fbb60 Clear thread pool task data on restart 2024-06-02 14:54:32 -04:00
Feoramund 45fa9d8148 Expand documentation comment for ODIN_TEST_NAMES 2024-06-02 14:54:32 -04:00
Feoramund cb8faf5b74 Remove -test-name in favor of test runner option
`-define:ODIN_TEST_NAMES=...` is capable of selecting test by package
and name or name only, with the ability to access packages included by
`-all-packages`.
2024-06-02 14:54:32 -04:00
Feoramund 6a5d51f0d6 Use more concise way of satisfying -vet 2024-06-02 14:54:31 -04:00
Feoramund 433ca538bf Be specific about platforms not implementing test runner signal handler 2024-06-02 14:54:31 -04:00
Feoramund d1723664a7 Catch SIGILL, SIGFPE, SIGSEGV in the test runner 2024-06-02 14:54:31 -04:00
Feoramund fb37572c4c Rename signal_handler.odin to signal_handler_libc.odin 2024-06-02 14:54:31 -04:00
Jeroen van Rijn 6050bc3bf6 Add missing benchmarks build.bat. 2024-06-02 14:54:31 -04:00
Jeroen van Rijn 306169699c Update ci.yml 2024-06-02 14:54:31 -04:00
Jeroen van Rijn 3354212f8e Update ci.yml
Disable benchmark on Windows for a moment.
2024-06-02 14:54:31 -04:00
Jeroen van Rijn 54dae06ad1 Update CI 2024-06-02 14:54:31 -04:00
Jeroen van Rijn 8d93379e29 Factor benchmarks out into tests\benchmark\<pkg> 2024-06-02 14:54:29 -04:00
Jeroen van Rijn 62b7d8de97 Port tests\core\net 2024-06-02 14:47:09 -04:00
Jeroen van Rijn dacb0f7786 Port tests\core\thread 2024-06-02 14:47:09 -04:00
Jeroen van Rijn 5b1ffba915 Port testing\core\time 2024-06-02 14:47:09 -04:00
Jeroen van Rijn a406ff7063 Port tests\core\strings 2024-06-02 14:47:09 -04:00
Jeroen van Rijn 9ba02e888d Port tests\core\slice 2024-06-02 14:47:09 -04:00
Jeroen van Rijn ed0384c102 Port tests\core\runtime 2024-06-02 14:47:09 -04:00
Jeroen van Rijn 80b115748f Port tests\core\reflect 2024-06-02 14:47:09 -04:00
Jeroen van Rijn 9829a02571 Port tests\core\odin 2024-06-02 14:47:09 -04:00
Jeroen van Rijn 8383a45b62 Port tests\core\text\match 2024-06-02 14:47:09 -04:00
Jeroen van Rijn b0faab29e0 Port tests\core\math, math\linalg\glsl and math\noise 2024-06-02 14:47:09 -04:00
Jeroen van Rijn d7bfbe0552 Port testing\core\text\i18n 2024-06-02 14:47:08 -04:00
Jeroen van Rijn 39fd73fe17 Port testing\core\hash 2024-06-02 14:47:08 -04:00
Jeroen van Rijn 6f7c5a7577 Port tests\core\fmt 2024-06-02 14:47:08 -04:00
Jeroen van Rijn d334b8c72a Port tests\core\path\filepath 2024-06-02 14:47:08 -04:00
Jeroen van Rijn 9d0f4833bf Port tests\core\encoding\xml
Made them run in parallel as well.
2024-06-02 14:47:08 -04:00
Jeroen van Rijn 6641a6f6c9 Port tests\core\encoding\varint 2024-06-02 14:47:08 -04:00
Jeroen van Rijn 601df0e8f7 Port tests\core\encoding\json 2024-06-02 14:47:08 -04:00
Jeroen van Rijn 1b32e27aa4 Port tests\core\encoding\hxa
And fix a few leaks in `core:encoding/hxa` while at it.
2024-06-02 14:47:08 -04:00
Jeroen van Rijn 3404dea8ac Port tests\encoding\hex 2024-06-02 14:47:08 -04:00
Jeroen van Rijn 40b20fb473 Port tests\core\c\libc 2024-06-02 14:47:08 -04:00
Feoramund b74b956fda Remove unneeded import 2024-06-02 14:47:08 -04:00
Feoramund 1f6a6f2cd3 Support deterministic random seeding of tests
Add a new option `ODIN_TEST_RANDOM_SEED` which is picked from the cycle
counter at startup, if it's not specified by the user.

This number is sent to every test in the `T` struct and reset every test
(just in case).
2024-06-02 14:47:07 -04:00
Jeroen van Rijn a27b167218 Update tests\core\encoding\cbor to use new test runner.
It was leaky and required a substantial number of `loc := #caller_location` additions to parts of the core library to make it easier to track down how and where it leaked.

The tests now run fine multi-threaded.
2024-06-02 14:47:07 -04:00
Jeroen van Rijn 6a1649d8aa Update using new defaults for memory + reporting width 2024-06-02 14:47:07 -04:00
Feoramund 84ad71fdb3 Support ODIN_TEST_PROGRESS_WIDTH=0
This will automatically calculate how wide the progress bars should be
based on the package with the greatest number of tests.

The progress width is now capped to 100.
2024-06-02 14:47:07 -04:00
Feoramund 49fa66370f Report test memory usage only if there's an issue
Adds new option `ODIN_TEST_ALWAYS_REPORT_MEMORY`, for when you always
want to see the memory usage report.
2024-06-02 14:47:07 -04:00
Feoramund e1a3c0e21d Track memory in the test runner by default 2024-06-02 14:47:07 -04:00
Feoramund bf42e39b1c Be specific about int size for Rollback_Stack asserts
This should fix tests failing on 32-bit platforms.
2024-06-02 14:47:07 -04:00
Jeroen van Rijn c531427ee5 Update -define for crypto 2024-06-02 14:47:07 -04:00
Feoramund b7e1ae7073 Change test runner options to SCREAMING_SNAKE_CASE
This commit also changes the name of `test_select` to `ODIN_TEST_NAMES`,
to better conform with the already-existing `-test-name:<name>` option.
2024-06-02 14:47:07 -04:00
Feoramund e11f3d2520 Fix missing - for define in tests/core/build.bat 2024-06-02 14:47:07 -04:00
Feoramund dcfda195d2 Send terminal control code to STDOUT instead
`STDERR` might be redirected, and this code signals to the terminal to
show the cursor again. Otherwise, the cursor will be invisible.
2024-06-02 14:47:07 -04:00
Feoramund a1c5bebac7 Fix ANSI redraw eating last log line 2024-06-02 14:47:07 -04:00
Feoramund 89d8df28be Combine multi-line attributes onto one line 2024-06-02 14:47:07 -04:00
Feoramund dffc3af86c Remove safe_heap_allocator from test runner
I was under the impression that the default `context.allocator` was not
thread-safe, but I've been told that this is not the case.
2024-06-02 14:47:06 -04:00
Feoramund eadfbb1318 Forbid singleton allocations from shrinking their block offset 2024-06-02 14:47:06 -04:00
Feoramund 1afc235359 Use plain sort for internal_tests 2024-06-02 14:47:06 -04:00
Feoramund 09ef08f035 Add more sanity checking to mem.Rollback_Stack 2024-06-02 14:47:06 -04:00
Feoramund 0f675fa436 Use uintptr where applicable in mem.Rollback_Stack 2024-06-02 14:47:06 -04:00
Feoramund 568b746c98 Fix indentation 2024-06-02 14:47:06 -04:00
Jeroen van Rijn a0b2ea6d6e Update tests\core\crypto 2024-06-02 14:46:59 -04:00
Jeroen van Rijn a463e282db Update core:container tests 2024-06-02 14:34:31 -04:00
Jeroen van Rijn e3181c13c6 Update core:compress tests 2024-06-02 14:34:31 -04:00
Jeroen van Rijn 22c092f846 Delete duplicated flag. 2024-06-02 14:34:31 -04:00
Jeroen van Rijn eb3d6d7d75 Update core:image tests to use new runner. 2024-06-02 14:34:31 -04:00
Feoramund 852f694bee Get tests passing again
`T` no longer has a writer assigned to it.

`test_core_cbor.odin` has global state and is run with `odin test`,
so I've set it to use only one thread.
2024-06-02 14:34:31 -04:00
Feoramund 87ea4a2652 Temporarily disable Windows-specific test runner
I do not have a Windows machine to test the refactored test runner, and
I am unsure if it would even run correctly on Windows without this
disabled.
2024-06-02 14:34:31 -04:00
Feoramund d03024088a Remove unneeded code 2024-06-02 14:34:31 -04:00
Feoramund b6c4dfb68d Refactor the test runner
Changes

- Support multi-threaded testing.
- Support `set_fail_timeout` on all platforms.
- Display an animated progress report.
- Setup all tests with a context logger.
- Give all tests their own separate custom allocators.
- Support tracking test memory usage.
- Display a summary of the failed tests at the end.
- Let users select only specific tests to run.
- Support copying failed tests to the clipboard to run again.
- Support catching SIGINT (CTRL-C) to cancel early.
- Record context in cleanup procs.
- Write all log messages to STDERR for easy redirection.
- Possibly more I've forgotten.

New Options

- `-define:test_threads=N`: Specify thread count.
- `-define:test_thread_memory=B`: Specify initial memory block size in bytes to each thread.
- `-define:test_track_memory=true`: Track the memory usage of individual tests.
- `-define:test_fancy=false`: Disable animated progress report.
- `-define:test_select=package.test_name,...`: Run only select tests.
- `-define:test_clipboard=true`: Copy names of failed tests to the clipboard.
- `-define:test_progress_width=24`: Change the width of the animated progress bars.
2024-06-02 14:34:31 -04:00
Feoramund 95c2e020ff Share libc signal definitions with more platforms
I confirmed that these 3 platforms share the same signal definitions
from these sources.

Haiku: https://github.com/haiku/haiku/blob/master/headers/posix/signal.h
OpenBSD: https://github.com/openbsd/src/blob/master/sys/sys/signal.h
NetBSD: http://fxr.watson.org/fxr/source/sys/signal.h?v=NETBSD
2024-06-02 14:34:30 -04:00
Feoramund 50dffaf131 Add mem.Rollback_Stack 2024-06-02 14:34:30 -04:00
Feoramund fc4f6b87bb Add core:encoding/ansi package 2024-06-02 14:34:30 -04:00
Feoramund 8137b9dd75 Add mem.tracking_allocator_reset 2024-06-02 14:34:30 -04:00
Feoramund 558c330028 Add task-stopping functionality to thread.Pool 2024-06-02 14:34:30 -04:00
Feoramund 1875e7c36a Make log.do_*_header argument orders consistent 2024-06-02 14:34:30 -04:00
Feoramund 7d4da6eaa7 Fix trailing space with only .Date log option 2024-06-02 14:34:30 -04:00
Feoramund 8ae375dbff Move log timestamping out to do_time_header proc 2024-06-02 14:34:30 -04:00
ed 66c85cb42c Merge remote-tracking branch 'offical/master' 2024-05-31 14:08:21 -04:00
ed ea2d35c608 Update ast_kinds.hpp with foreign import changes 2024-05-30 13:27:37 -04:00
ed fba6f5ddc0 Merge remote-tracking branch 'offical/master' 2024-05-30 13:20:34 -04:00
korvahkh a7a6ff8c69 encoding/json: Fix struct marshal() emitting comma after omitted field
Previously:
```odin
package main

import "core:fmt"
import "core:encoding/json"

T :: struct {
	a: string `json:",omitempty"`,
	b: string,
}

main :: proc() {
	data, _ := json.marshal(T{b = "foo"})
	fmt.println(string(data))
}
```
would output:
```
{,"b":"foo"}
```

which is not correct.

Also cleaned up some whitespace while I'm at it.
2024-05-27 16:59:46 -05:00
ed 71d62aaeb7 Merge remote-tracking branch 'offical/master' 2024-05-26 10:50:16 -04:00
ed 0709576f9e Added built script for the compiler (to run gen_src.cpp beforehand) 2024-05-26 10:50:09 -04:00
tim4242 0cba33075f Add the option to export dependencies as JSON. 2024-05-24 13:44:38 +02:00
tim4242 8664b88c8f Improved depdendency formatting to support paths containing spaces 2024-05-24 01:20:45 +02:00
tim4242 7934e92d14 Initial dependency file generation 2024-05-24 01:04:41 +02:00
ed 389e12a785 Fixed read_directory_recursive not enforcing all nested subdirectories to be part of the same package when .ODIN_MONOLITHIC_PACKAGE on package directory 2024-05-18 14:17:03 -04:00
ed 6cff778944 Formatting fixes for read_directory_recursive 2024-05-16 17:32:16 -04:00
ed 494c9ce08e Merge remote-tracking branch 'offical/master' 2024-05-16 17:18:43 -04:00
ed 427d2e0d83 Added support for monolithic packages
Not sure if the base name for them, lets the user by specifying a .ODIN_MONOLITHIC_PACKAGE;
make compiler assume that all files in child directories are part of the same package (making a uniform prackage across subdirectoreis).
2024-05-16 17:18:32 -04:00
ed 05577a2378 Now running git restore before running codegen/gen_src.cpp 2024-05-16 10:59:51 -04:00
ed f127d0f7ed Merge remote-tracking branch 'offical/master' 2024-05-16 10:32:49 -04:00
ed 67ae530d22 Merge remote-tracking branch 'offical/master' 2024-05-16 09:42:57 -04:00
ed a4c9479a56 misc changes 2024-05-15 00:19:01 -04:00
ed fffc667ab7 Merge remote-tracking branch 'offical/master' 2024-05-14 06:17:25 -04:00
ed 0d4069d2ea Merge remote-tracking branch 'offical/master' 2024-05-12 14:02:47 -04:00
ed 1db5fb32cd Bodged in support for region pragmas
Have them as basic directives

They're similar to the assert and panic macros but are hardcoded to true

#region    (<string literal>)
#endregion (<string literal>)
2024-05-12 14:02:38 -04:00
ed e462116f94 Merge remote-tracking branch 'offical/master' 2024-05-10 11:10:02 -04:00
ed e1b5ccf2dc Merge remote-tracking branch 'offical/master' 2024-05-10 02:03:51 -04:00
ed 373733fb2b Merge remote-tracking branch 'offical/master' 2024-05-07 18:03:37 -04:00
ed 647d7ed9e3 Minor fixes to gencpp formatting 2024-05-05 21:29:19 -04:00
ed 3641306ef2 Merge remote-tracking branch 'offical/master'
# Conflicts:
#	.gitignore
2024-05-05 20:00:13 -04:00
ed ca63883f78 TYPE_KINDs macro swappable with codegen/gen_src.cpp 2024-05-05 02:43:27 -04:00
ed a33492da24 TOKEN_KINDs macro swappable with codegen/gen_src.cpp 2024-05-05 01:46:32 -04:00
ed f727f3ccb1 codegen/gen_src.cpp fixes for building with metaprogram clang 2024-05-05 00:12:11 -04:00
ed bc45aa80b6 gen_src supports swapping AST_KINDS macros in parser.hpp
- Minor fixes to gencpp
- Adjust .clang-format to be similar to the codebase's conventions
2024-05-05 00:09:38 -04:00
ed cd3803fb37 Adjusted gencpp for odin's codebase 2024-05-04 19:37:08 -04:00
ed 1c633f7306 Setup codegen metaprogram skeleton
Going use it to swap macro implementation usage in the compiler.
2024-05-04 15:23:33 -04:00
ed fa82547705 Merge remote-tracking branch 'offical/master' 2024-05-03 19:36:07 -04:00
ed b62e3a98c6 Merge remote-tracking branch 'offical/master' 2024-04-30 15:28:31 -04:00
Timo 2918baa3e8 Update builder.odin
Modify documentation-text for procedure write_f64 :

change type f32 to f64
2024-04-29 20:22:53 +02:00
Artsiom Babukh 805bb69c6c Fix typo in core_builtin 2024-04-28 15:27:34 +00:00
PucklaJ 37b026cb9b [sys/linux] Directly call syscall in execve on arm64 2024-04-28 12:00:40 +02:00
PucklaJ d1a205e2cf [sys/linux]: Remove clone syscall and call it directly in fork on arm64 2024-04-28 11:56:19 +02:00
PucklaJ 7f301790d0 [sys/linux] Change flags parameter of execveat to bit_set 2024-04-28 11:48:18 +02:00
PucklaJ b0fe6212bb [sys/linux]: Fix return statement 2024-04-27 13:21:04 +02:00
ed 20a436b6a8 Merge remote-tracking branch 'offical/master' 2024-04-24 10:08:37 -04:00
PucklaJ a2ad66cd9d [sys/linux]: Add clone syscall and use it in fork for arm64 2024-04-24 15:32:43 +02:00
PucklaJ 2bf00d9b3f [sys/linux]: Add flags parameter to execveat and fix execve on arm64 2024-04-24 15:15:38 +02:00
alec hodgkinson 3b632b4d90 Fixed typo in raylib documentation 2024-04-22 15:13:52 -07:00
ed d68dba3677 Merge remote-tracking branch 'offical/master' 2024-04-14 19:42:56 -04:00
ed a1f241e925 Merge remote-tracking branch 'offical/master' 2024-04-06 13:49:21 -04:00
ed 141adaf12e Merge remote-tracking branch 'offical/master' 2024-03-30 13:03:37 -04:00
ed 8ea5aaa81b Merge remote-tracking branch 'offical/master' 2024-03-27 13:19:18 -04:00
Arseniy Poroshin 77a0e50298 fix comments in core:container/queue. 2024-03-26 22:39:43 +00:00
ed e03fa88e4c Merge remote-tracking branch 'offical/master' 2024-03-25 18:44:26 -04:00
ed 4e16389d60 Merge remote-tracking branch 'offical/master' 2024-03-20 15:21:14 -04:00
ed fe500e2904 Merge remote-tracking branch 'offical/master' 2024-03-20 09:09:02 -04:00
ed d9e318a220 Merge remote-tracking branch 'offical/master' 2024-03-19 16:30:36 -04:00
ed 5dadf56000 Merge remote-tracking branch 'offical/master' 2024-03-19 11:48:27 -04:00
Beau McCartney 43e8da2e06 shm_open: comment with notes abt permissions 2024-03-19 09:36:49 -06:00
ed 8467c2c4a4 Merge remote-tracking branch 'offical/master' 2024-03-19 08:37:25 -04:00
ed 338d16504c Merge remote-tracking branch 'offical/master' 2024-03-18 11:46:03 -04:00
Beau McCartney 1758bd683e sys_shm_open: fchmod the returned descriptor to get correct perms
this doesn't happen by default
2024-03-16 12:13:00 -06:00
Eric Johnson 4b7f32c287 Update mem doc example formatting 2024-03-15 12:26:01 -07:00
Beau McCartney 24f9e16dfd sys_open() calls _sys_open_mode() to get a permission flags integer
_sys_open_mode() does exactly what sys_open() was originally doing
inline, I simply factored it into a separate function so that other
wrappers could call it (similar to _sys_permission_mode())
2024-03-15 08:32:25 -06:00
Beau McCartney 56a29685b4 darwin: sys_shm_open() helper
wraps syscall_shm_open() in the same way that sys_open() wraps
syscall_open()
2024-03-15 08:27:27 -06:00
Beau McCartney cf949e541f helper function to convert Open_Flags bitset to a u32
- analagous to _sys_permission_mode()
- uses the already-existing conversion logic in sys_open()
2024-03-15 08:26:25 -06:00
Beau McCartney 44167800ad darwin: syscall wrappers for shm_open() and shm_unlink() 2024-03-15 08:26:03 -06:00
ed 2949802070 Merge remote-tracking branch 'offical/master' 2024-03-12 20:58:20 -04:00
ed f117910835 Merge remote-tracking branch 'offical/master' 2024-03-11 22:57:47 -04:00
ed fdfec5cf82 Merge remote-tracking branch 'offical/master' 2024-03-09 14:53:25 -05:00
ed c448b34143 Merge remote-tracking branch 'offical/master' 2024-03-08 17:47:40 -05:00
ed 00e3c3d94d Updated raylib vendor package to default to shared in config and with SUPPORT_CUSTOM_FRAME_CONTROL enabled 2024-03-08 15:39:22 -05:00
ed 242d5b8c5c Merge remote-tracking branch 'offical/master' 2024-03-07 16:09:23 -05:00
ed 57712343be Merge remote-tracking branch 'offical/master' 2024-03-06 16:42:22 -05:00
ed 72f38afb04 Make core::os get_page_size contextless 2024-03-06 00:52:31 -05:00
ed 9525a3a135 Merge remote-tracking branch 'offical/master'
# Conflicts:
#	vendor/raylib/raylib.odin
2024-03-05 20:24:08 -05:00
ed ddf5257868 Merge remote-tracking branch 'offical/master' 2024-02-22 15:31:38 -05:00
ed b33ddc8f0e Merge remote-tracking branch 'offical/master' 2024-02-22 10:07:23 -05:00
ed 01ec8856a9 Merge remote-tracking branch 'offical/master' 2024-02-21 15:58:24 -05:00
Ali Salehi 8aab0f9e34 Add distinct and remove unnecessary link_names 2024-02-19 15:55:57 +01:00
Ali Salehi d380e43166 Add xinput bindings to core:sys/windows 2024-02-18 21:28:30 +01:00
ed 2b6de7fe3e Merge remote-tracking branch 'origin/master' 2024-02-13 13:40:50 -05:00
ed b9e5f027eb Change raylib.Camera2D.chars to glyphs 2024-02-12 12:05:49 -05:00
marcs feh 9c6574e053 Merge branch 'odin-lang:master' into master 2024-02-11 23:55:39 +00:00
ed 02446a8381 Merge remote-tracking branch 'origin/master' 2024-02-09 13:40:31 -05:00
ed 9c55b6ea44 Merge remote-tracking branch 'origin/master' 2024-02-08 22:35:38 -05:00
ed 7eb61537c6 Merge remote-tracking branch 'origin/master' 2024-02-07 15:23:49 -05:00
ed fc80a5118b Merge remote-tracking branch 'origin/master' 2024-02-03 11:40:28 -05:00
marcs feh fc113315f6 Merge branch 'odin-lang:master' into master 2024-02-02 21:56:40 -03:00
ed b2bb84d3b1 Merge remote-tracking branch 'origin/master' 2024-01-29 09:27:03 -05:00
marcs-feh d931bfcf83 resolve conflict 2024-01-26 16:23:16 -03:00
marcs-feh b58627490b Adjust signture + Fix rebase conflict 2024-01-26 12:10:15 -03:00
ed 931f791e24 Build raylib shared 2024-01-25 11:07:08 -05:00
marcs feh dbaa82b581 Merge branch 'odin-lang:master' into master 2024-01-24 20:10:44 -03:00
marcs-feh 84123cc879 sys/linux: Adjust ioctl signature to fit the actual Linux Kernel implementation 2024-01-24 13:40:50 -03:00
marcs-feh 7b1f58a06a sys/linux: Add binding to ioctl syscall + fd consts
Add binding to ioctl syscall, due to the vast nature of this syscall
adding more device specific request values is possible. Also added the
stdin, stdout and stderr, to constants.odin
2024-01-22 16:09:44 -03:00
mfalk bd96cd0af7 Fixed indentation and : binding 2023-12-04 05:49:42 +01:00
jakubtomsu fe268a9dd2 Add nullptr check back 2023-11-25 13:29:28 +01:00
jakubtomsu 3c25d93eae Check for variadic param default val 2023-11-25 13:20:34 +01:00
mfalk 6dffd412f9 Adding IUserDefinedAnnotation to D3D11 for better debugging. 2023-11-09 16:46:07 +01:00
1645 changed files with 368533 additions and 51886 deletions
+214 -150
View File
@@ -6,11 +6,11 @@ jobs:
name: NetBSD Build, Check, and Test
runs-on: ubuntu-latest
env:
PKGSRC_BRANCH: 2024Q1
PKGSRC_BRANCH: 2025Q2
steps:
- uses: actions/checkout@v4
- name: Build, Check, and Test
timeout-minutes: 25
timeout-minutes: 15
uses: vmactions/netbsd-vm@v1
with:
release: "10.0"
@@ -18,163 +18,173 @@ jobs:
usesh: true
copyback: false
prepare: |
PKG_PATH="https://cdn.NetBSD.org/pub/pkgsrc/packages/NetBSD/$(uname -p)/$(uname -r | cut -d_ -f1)_${PKGSRC_BRANCH}/All" /usr/sbin/pkg_add pkgin
pkgin -y in gmake git bash python311
pkgin -y in libxml2 perl zstd
/usr/sbin/pkg_add https://github.com/andreas-jonsson/llvm17-netbsd-bin/releases/download/pkgsrc-current/llvm-17.0.6.tgz
/usr/sbin/pkg_add https://github.com/andreas-jonsson/llvm17-netbsd-bin/releases/download/pkgsrc-current/clang-17.0.6.tgz
PKG_PATH="https://cdn.NetBSD.org/pub/pkgsrc/packages/NetBSD/amd64/$(uname -r | cut -d_ -f1)_${PKGSRC_BRANCH}/All" /usr/sbin/pkg_add pkgin
pkgin -y in gmake git bash python311 llvm clang
ln -s /usr/pkg/bin/python3.11 /usr/bin/python3
ln -s /usr/pkg/bin/bash /bin/bash
run: |
set -e -x
git config --global --add safe.directory $(pwd)
gmake release
./odin version
./odin report
./odin check examples/all -vet -strict-style -target:netbsd_amd64
(cd tests/core; gmake all_bsd)
(cd tests/internal; gmake all_bsd)
gmake -C vendor/stb/src
gmake -C vendor/cgltf/src
gmake -C vendor/miniaudio/src
./odin check examples/all -vet -vet-tabs -strict-style -vet-style -warnings-as-errors -disallow-do -target:netbsd_amd64
./odin check examples/all -vet -vet-tabs -strict-style -vet-style -warnings-as-errors -disallow-do -target:netbsd_arm64
./odin check examples/all/sdl3 -vet -vet-tabs -strict-style -vet-style -warnings-as-errors -disallow-do -target:netbsd_amd64 -no-entry-point
./odin check examples/all/sdl3 -vet -vet-tabs -strict-style -vet-style -warnings-as-errors -disallow-do -target:netbsd_arm64 -no-entry-point
./odin test tests/core/normal.odin -file -all-packages -vet -vet-tabs -strict-style -vet-style -warnings-as-errors -disallow-do -define:ODIN_TEST_FANCY=false -define:ODIN_TEST_FAIL_ON_BAD_MEMORY=true
./odin test tests/core/speed.odin -file -vet -vet-tabs -strict-style -vet-style -warnings-as-errors -disallow-do -o:speed -define:ODIN_TEST_FANCY=false -define:ODIN_TEST_FAIL_ON_BAD_MEMORY=true
./odin test tests/vendor -all-packages -vet -vet-tabs -strict-style -vet-style -warnings-as-errors -disallow-do -define:ODIN_TEST_FANCY=false -define:ODIN_TEST_FAIL_ON_BAD_MEMORY=true
(cd tests/issues; ./run.sh)
build_linux:
name: Ubuntu Build, Check, and Test
./odin check tests/benchmark -vet -strict-style -no-entry-point
build_freebsd:
name: FreeBSD Build, Check, and Test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- name: Download LLVM
- uses: actions/checkout@v4
- name: Build, Check, and Test
timeout-minutes: 15
uses: vmactions/freebsd-vm@v1
with:
usesh: true
copyback: false
prepare: |
pkg install -y gmake git bash python3 libxml2 llvm18
run: |
# `set -e` is needed for test failures to register. https://github.com/vmactions/freebsd-vm/issues/72
set -e -x
git config --global --add safe.directory $(pwd)
gmake release
./odin version
./odin report
gmake -C vendor/stb/src
gmake -C vendor/cgltf/src
gmake -C vendor/miniaudio/src
./odin check examples/all -vet -vet-tabs -strict-style -vet-style -warnings-as-errors -disallow-do -target:freebsd_amd64
./odin check examples/all/sdl3 -vet -vet-tabs -strict-style -vet-style -warnings-as-errors -disallow-do -target:freebsd_amd64 -no-entry-point
./odin test tests/core/normal.odin -file -all-packages -vet -vet-tabs -strict-style -vet-style -warnings-as-errors -disallow-do -define:ODIN_TEST_FANCY=false -define:ODIN_TEST_FAIL_ON_BAD_MEMORY=true
./odin test tests/core/speed.odin -file -all-packages -vet -vet-tabs -strict-style -vet-style -warnings-as-errors -disallow-do -o:speed -define:ODIN_TEST_FANCY=false -define:ODIN_TEST_FAIL_ON_BAD_MEMORY=true
./odin test tests/vendor -all-packages -vet -vet-tabs -strict-style -vet-style -warnings-as-errors -disallow-do -define:ODIN_TEST_FANCY=false -define:ODIN_TEST_FAIL_ON_BAD_MEMORY=true
(cd tests/issues; ./run.sh)
./odin check tests/benchmark -vet -strict-style -no-entry-point
ci:
strategy:
fail-fast: false
matrix:
# MacOS 13 runs on Intel, 14 runs on ARM
os: [macos-14, ubuntu-latest]
runs-on: ${{ matrix.os }}
name: ${{ matrix.os == 'macos-14' && 'MacOS ARM' || (matrix.os == 'macos-13' && 'MacOS Intel') || (matrix.os == 'ubuntu-latest' && 'Ubuntu') }} Build, Check, and Test
timeout-minutes: 15
steps:
- uses: actions/checkout@v4
- name: Download LLVM (MacOS Intel)
if: matrix.os == 'macos-13'
run: |
brew update
brew install llvm@20 lua@5.4 lld
echo "$(brew --prefix llvm@20)/bin" >> $GITHUB_PATH
- name: Download LLVM (MacOS ARM)
if: matrix.os == 'macos-14'
run: |
brew update
brew install llvm@20 wasmtime lua@5.4 lld
echo "$(brew --prefix llvm@20)/bin" >> $GITHUB_PATH
- name: Download LLVM (Ubuntu)
if: matrix.os == 'ubuntu-latest'
run: |
wget https://apt.llvm.org/llvm.sh
chmod +x llvm.sh
sudo ./llvm.sh 17
echo "/usr/lib/llvm-17/bin" >> $GITHUB_PATH
- name: build odin
sudo ./llvm.sh 20
echo "/usr/lib/llvm-20/bin" >> $GITHUB_PATH
- name: Build Odin
run: ./build_odin.sh release
- name: Odin version
run: ./odin version
timeout-minutes: 1
- name: Odin report
run: ./odin report
timeout-minutes: 1
- name: Compile needed Vendor
run: |
make -C vendor/stb/src
make -C vendor/cgltf/src
make -C vendor/miniaudio/src
- name: Odin check
run: ./odin check examples/demo -vet
timeout-minutes: 10
- name: Odin run
run: ./odin run examples/demo
timeout-minutes: 10
- name: Odin run -debug
run: ./odin run examples/demo -debug
timeout-minutes: 10
- name: Odin check examples/all
run: ./odin check examples/all -strict-style
timeout-minutes: 10
- name: Core library tests
run: |
cd tests/core
make
timeout-minutes: 10
run: ./odin check examples/all -vet -vet-tabs -strict-style -vet-style -warnings-as-errors -disallow-do
- name: Odin check examples/all/sdl3
run: ./odin check examples/all/sdl3 -vet -vet-tabs -strict-style -vet-style -warnings-as-errors -disallow-do -no-entry-point
- name: Normal Core library tests
run: ./odin test tests/core/normal.odin -file -all-packages -vet -vet-tabs -strict-style -vet-style -warnings-as-errors -disallow-do -define:ODIN_TEST_FANCY=false -define:ODIN_TEST_FAIL_ON_BAD_MEMORY=true -sanitize:address
- name: Optimized Core library tests
run: ./odin test tests/core/speed.odin -o:speed -file -all-packages -vet -vet-tabs -strict-style -vet-style -warnings-as-errors -disallow-do -define:ODIN_TEST_FANCY=false -define:ODIN_TEST_FAIL_ON_BAD_MEMORY=true -sanitize:address
- name: Vendor library tests
run: ./odin test tests/vendor -all-packages -vet -vet-tabs -strict-style -vet-style -warnings-as-errors -disallow-do -define:ODIN_TEST_FANCY=false -define:ODIN_TEST_FAIL_ON_BAD_MEMORY=true -sanitize:address
- name: Internals tests
run: ./odin test tests/internal -all-packages -vet -vet-tabs -strict-style -vet-style -warnings-as-errors -disallow-do -define:ODIN_TEST_FANCY=false -define:ODIN_TEST_FAIL_ON_BAD_MEMORY=true -sanitize:address
- name: GitHub Issue tests
run: |
cd tests/vendor
make
timeout-minutes: 10
- name: Odin internals tests
cd tests/issues
./run.sh
- name: Run demo on WASI WASM32
run: |
cd tests/internal
make
timeout-minutes: 10
./odin build examples/demo -target:wasi_wasm32 -vet -vet-tabs -strict-style -vet-style -warnings-as-errors -disallow-do -out:demo
wasmtime ./demo.wasm
if: matrix.os == 'macos-14'
- name: Check benchmarks
run: ./odin check tests/benchmark -vet -vet-tabs -strict-style -vet-style -warnings-as-errors -disallow-do -no-entry-point
- name: Odin check examples/all for Linux i386
run: ./odin check examples/all -vet -strict-style -target:linux_i386
timeout-minutes: 10
if: matrix.os == 'ubuntu-latest'
run: ./odin check examples/all -vet -vet-tabs -strict-style -vet-style -warnings-as-errors -disallow-do -target:linux_i386
- name: Odin check examples/all for Linux arm64
run: ./odin check examples/all -vet -strict-style -target:linux_arm64
timeout-minutes: 10
if: matrix.os == 'ubuntu-latest'
run: ./odin check examples/all -vet -vet-tabs -strict-style -vet-style -warnings-as-errors -disallow-do -target:linux_arm64
- name: Odin check examples/all for FreeBSD amd64
run: ./odin check examples/all -vet -strict-style -target:freebsd_amd64
timeout-minutes: 10
if: matrix.os == 'ubuntu-latest'
run: ./odin check examples/all -vet -vet-tabs -strict-style -vet-style -warnings-as-errors -disallow-do -target:freebsd_amd64
- name: Odin check examples/all for OpenBSD amd64
run: ./odin check examples/all -vet -strict-style -target:openbsd_amd64
timeout-minutes: 10
build_macOS:
name: MacOS Build, Check, and Test
runs-on: macos-13
steps:
- uses: actions/checkout@v1
- name: Download LLVM, and setup PATH
run: |
brew install llvm@17
echo "/usr/local/opt/llvm@17/bin" >> $GITHUB_PATH
- name: build odin
run: ./build_odin.sh release
- name: Odin version
run: ./odin version
timeout-minutes: 1
- name: Odin report
run: ./odin report
timeout-minutes: 1
- name: Odin check
run: ./odin check examples/demo -vet
timeout-minutes: 10
- name: Odin run
run: ./odin run examples/demo
timeout-minutes: 10
- name: Odin run -debug
run: ./odin run examples/demo -debug
timeout-minutes: 10
- name: Odin check examples/all
run: ./odin check examples/all -strict-style
timeout-minutes: 10
- name: Core library tests
run: |
cd tests/core
make
timeout-minutes: 10
- name: Odin internals tests
run: |
cd tests/internal
make
timeout-minutes: 10
build_macOS_arm:
name: MacOS ARM Build, Check, and Test
runs-on: macos-14 # This is an arm/m1 runner.
steps:
- uses: actions/checkout@v1
- name: Download LLVM and setup PATH
run: |
brew install llvm@17
echo "/opt/homebrew/opt/llvm@17/bin" >> $GITHUB_PATH
- name: build odin
run: ./build_odin.sh release
- name: Odin version
run: ./odin version
timeout-minutes: 1
- name: Odin report
run: ./odin report
timeout-minutes: 1
- name: Odin check
run: ./odin check examples/demo -vet
timeout-minutes: 10
- name: Odin run
run: ./odin run examples/demo
timeout-minutes: 10
- name: Odin run -debug
run: ./odin run examples/demo -debug
timeout-minutes: 10
- name: Odin check examples/all
run: ./odin check examples/all -strict-style
timeout-minutes: 10
- name: Core library tests
run: |
cd tests/core
make
timeout-minutes: 10
- name: Odin internals tests
run: |
cd tests/internal
make
timeout-minutes: 10
if: matrix.os == 'ubuntu-latest'
run: ./odin check examples/all -vet -vet-tabs -strict-style -vet-style -warnings-as-errors -disallow-do -target:openbsd_amd64
- name: Odin check examples/all for js_wasm32
if: matrix.os == 'ubuntu-latest'
run: ./odin check examples/all -vet -vet-tabs -strict-style -vet-style -warnings-as-errors -disallow-do -no-entry-point -target:js_wasm32
- name: Odin check examples/all for js_wasm64p32
if: matrix.os == 'ubuntu-latest'
run: ./odin check examples/all -vet -vet-tabs -strict-style -vet-style -warnings-as-errors -disallow-do -no-entry-point -target:js_wasm64p32
- name: Odin check examples/all/sdl3 for Linux i386
if: matrix.os == 'ubuntu-latest'
run: ./odin check examples/all/sdl3 -vet -vet-tabs -strict-style -vet-style -warnings-as-errors -disallow-do -no-entry-point -target:linux_i386
- name: Odin check examples/all/sdl3 for Linux arm64
if: matrix.os == 'ubuntu-latest'
run: ./odin check examples/all/sdl3 -vet -vet-tabs -strict-style -vet-style -warnings-as-errors -disallow-do -no-entry-point -target:linux_arm64
- name: Odin check examples/all/sdl3 for FreeBSD amd64
if: matrix.os == 'ubuntu-latest'
run: ./odin check examples/all/sdl3 -vet -vet-tabs -strict-style -vet-style -warnings-as-errors -disallow-do -no-entry-point -target:freebsd_amd64
- name: Odin check examples/all/sdl3 for OpenBSD amd64
if: matrix.os == 'ubuntu-latest'
run: ./odin check examples/all/sdl3 -vet -vet-tabs -strict-style -vet-style -warnings-as-errors -disallow-do -no-entry-point -target:openbsd_amd64
build_windows:
name: Windows Build, Check, and Test
runs-on: windows-2022
timeout-minutes: 15
steps:
- uses: actions/checkout@v1
- uses: actions/checkout@v4
- name: build Odin
shell: cmd
run: |
@@ -182,72 +192,126 @@ jobs:
./build.bat 1
- name: Odin version
run: ./odin version
timeout-minutes: 1
- name: Odin report
run: ./odin report
timeout-minutes: 1
- name: Odin check
shell: cmd
run: |
call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvars64.bat
odin check examples/demo -vet
timeout-minutes: 10
- name: Odin run
shell: cmd
run: |
call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvars64.bat
odin run examples/demo
timeout-minutes: 10
- name: Odin run -debug
shell: cmd
run: |
call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvars64.bat
odin run examples/demo -debug
timeout-minutes: 10
odin run examples/demo -debug -vet -vet-tabs -strict-style -vet-style -warnings-as-errors -disallow-do
- name: Odin check examples/all
shell: cmd
run: |
call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvars64.bat
odin check examples/all -strict-style
timeout-minutes: 10
odin check examples/all -vet -vet-tabs -strict-style -vet-style -warnings-as-errors -disallow-do
- name: Odin check examples/all/sdl3
shell: cmd
run: |
call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvars64.bat
odin check examples/all/sdl3 -vet -vet-tabs -strict-style -vet-style -warnings-as-errors -disallow-do -no-entry-point
- name: Core library tests
shell: cmd
run: |
call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvars64.bat
cd tests\core
call build.bat
timeout-minutes: 10
odin test tests/core/normal.odin -file -all-packages -vet -vet-tabs -strict-style -vet-style -warnings-as-errors -disallow-do -define:ODIN_TEST_FANCY=false -define:ODIN_TEST_FAIL_ON_BAD_MEMORY=true -sanitize:address
- name: Optimized core library tests
shell: cmd
run: |
call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvars64.bat
odin test tests/core/speed.odin -o:speed -file -all-packages -vet -vet-tabs -strict-style -vet-style -warnings-as-errors -disallow-do -define:ODIN_TEST_FANCY=false -define:ODIN_TEST_FAIL_ON_BAD_MEMORY=true -sanitize:address
- name: Vendor library tests
shell: cmd
run: |
call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvars64.bat
cd tests\vendor
call build.bat
timeout-minutes: 10
copy vendor\lua\5.4\windows\*.dll .
odin test tests/vendor -all-packages -vet -vet-tabs -strict-style -vet-style -warnings-as-errors -disallow-do -define:ODIN_TEST_FANCY=false -define:ODIN_TEST_FAIL_ON_BAD_MEMORY=true -sanitize:address
- name: Odin internals tests
shell: cmd
run: |
call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvars64.bat
cd tests\internal
call build.bat
timeout-minutes: 10
odin test tests/internal -all-packages -vet -vet-tabs -strict-style -vet-style -warnings-as-errors -disallow-do -define:ODIN_TEST_FANCY=false -define:ODIN_TEST_FAIL_ON_BAD_MEMORY=true -sanitize:address
- name: Check issues
shell: cmd
run: |
call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvars64.bat
cd tests/issues
call run.bat
- name: Check benchmarks
shell: cmd
run: |
call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvars64.bat
odin check tests/benchmark -vet -strict-style -no-entry-point
- name: Odin documentation tests
shell: cmd
run: |
call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvars64.bat
cd tests\documentation
call build.bat
timeout-minutes: 10
- name: core:math/big tests
shell: cmd
run: |
call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvars64.bat
cd tests\core\math\big
call build.bat
timeout-minutes: 10
- name: Odin check examples/all for Windows 32bits
shell: cmd
run: |
call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvars64.bat
odin check examples/all -strict-style -target:windows_i386
timeout-minutes: 10
build_linux_riscv64:
runs-on: ubuntu-latest
name: Linux riscv64 (emulated) Build, Check and Test
timeout-minutes: 15
steps:
- uses: actions/checkout@v4
- name: Download LLVM (Linux)
run: |
wget https://apt.llvm.org/llvm.sh
chmod +x llvm.sh
sudo ./llvm.sh 18
echo "/usr/lib/llvm-18/bin" >> $GITHUB_PATH
- name: Build Odin
run: ./build_odin.sh release
- name: Odin version
run: ./odin version
- name: Odin report
run: ./odin report
- name: Compile needed Vendor
run: |
make -C vendor/stb/src
make -C vendor/cgltf/src
make -C vendor/miniaudio/src
- name: Odin check examples/all
run: ./odin check examples/all -target:linux_riscv64 -vet -vet-tabs -strict-style -vet-style -warnings-as-errors -disallow-do
- name: Odin check examples/all/sdl3
run: ./odin check examples/all/sdl3 -target:linux_riscv64 -vet -vet-tabs -strict-style -vet-style -warnings-as-errors -disallow-do -no-entry-point
- name: Install riscv64 toolchain and qemu
run: sudo apt-get install -y qemu-user qemu-user-static gcc-12-riscv64-linux-gnu libc6-riscv64-cross
- name: Odin run
run: ./odin run examples/demo -vet -vet-tabs -strict-style -vet-style -warnings-as-errors -disallow-do -target:linux_riscv64 -extra-linker-flags:"-fuse-ld=/usr/bin/riscv64-linux-gnu-gcc-12 -static -Wl,-static" -no-rpath
- name: Odin run -debug
run: ./odin run examples/demo -debug -vet -vet-tabs -strict-style -vet-style -warnings-as-errors -disallow-do -target:linux_riscv64 -extra-linker-flags:"-fuse-ld=/usr/bin/riscv64-linux-gnu-gcc-12 -static -Wl,-static" -no-rpath
- name: Normal Core library tests
run: ./odin test tests/core/normal.odin -file -all-packages -vet -vet-tabs -strict-style -vet-style -warnings-as-errors -disallow-do -define:ODIN_TEST_FANCY=false -define:ODIN_TEST_FAIL_ON_BAD_MEMORY=true -target:linux_riscv64 -extra-linker-flags:"-fuse-ld=/usr/bin/riscv64-linux-gnu-gcc-12 -static -Wl,-static" -no-rpath
- name: Optimized Core library tests
run: ./odin test tests/core/speed.odin -o:speed -file -all-packages -vet -vet-tabs -strict-style -vet-style -warnings-as-errors -disallow-do -define:ODIN_TEST_FANCY=false -define:ODIN_TEST_FAIL_ON_BAD_MEMORY=true -target:linux_riscv64 -extra-linker-flags:"-fuse-ld=/usr/bin/riscv64-linux-gnu-gcc-12 -static -Wl,-static" -no-rpath
- name: Internals tests
run: ./odin test tests/internal -all-packages -vet -vet-tabs -strict-style -vet-style -warnings-as-errors -disallow-do -define:ODIN_TEST_FANCY=false -define:ODIN_TEST_FAIL_ON_BAD_MEMORY=true -target:linux_riscv64 -extra-linker-flags:"-fuse-ld=/usr/bin/riscv64-linux-gnu-gcc-12 -static -Wl,-static" -no-rpath
+60
View File
@@ -0,0 +1,60 @@
name: Test Coverage
on: [push, pull_request, workflow_dispatch]
jobs:
build_linux_amd64:
runs-on: ubuntu-latest
name: Linux AMD64 Test Coverage
timeout-minutes: 60
steps:
- uses: actions/checkout@v4
- name: Download LLVM (Ubuntu)
if: matrix.os == 'ubuntu-latest'
run: |
wget https://apt.llvm.org/llvm.sh
chmod +x llvm.sh
sudo ./llvm.sh 20
echo "/usr/lib/llvm-20/bin" >> $GITHUB_PATH
- name: Install kcov
run: |
sudo apt-get update
sudo apt-get install binutils-dev build-essential cmake libssl-dev libcurl4-openssl-dev libelf-dev libstdc++-12-dev zlib1g-dev libdw-dev libiberty-dev
git clone https://github.com/SimonKagstrom/kcov.git
mkdir kcov/build
cd kcov/build
cmake ..
sudo make
sudo make install
cd ../..
kcov --version
- name: Build Odin
run: ./build_odin.sh release
- name: Odin report
run: ./odin report
- name: Normal Core library tests
run: |
./odin build tests/core/normal.odin -build-mode:test -debug -file -all-packages -vet -strict-style -disallow-do -define:ODIN_TEST_FANCY=false -define:ODIN_TEST_FAIL_ON_BAD_MEMORY=true -target:linux_amd64
mkdir kcov-out
kcov --exclude-path=tests,/usr kcov-out ./normal.bin .
- name: Optimized Core library tests
run: |
./odin build tests/core/speed.odin -build-mode:test -debug -file -all-packages -vet -strict-style -disallow-do -define:ODIN_TEST_FANCY=false -define:ODIN_TEST_FAIL_ON_BAD_MEMORY=true -target:linux_amd64
kcov --exclude-path=tests,/usr kcov-out ./speed.bin .
- name: Internals tests
run: |
./odin build tests/internal -build-mode:test -debug -all-packages -vet -strict-style -disallow-do -define:ODIN_TEST_FANCY=false -define:ODIN_TEST_FAIL_ON_BAD_MEMORY=true -target:linux_amd64
kcov --exclude-path=tests,/usr kcov-out ./internal .
- uses: codecov/codecov-action@v5
with:
name: Ubuntu Coverage # optional
token: ${{ secrets.CODECOV_TOKEN }}
verbose: true # optional (default = false
directory: kcov-out/kcov-merged
+151 -92
View File
@@ -11,7 +11,7 @@ jobs:
if: github.repository == 'odin-lang/Odin'
runs-on: windows-2022
steps:
- uses: actions/checkout@v1
- uses: actions/checkout@v4
- name: build Odin
shell: cmd
run: |
@@ -36,149 +36,221 @@ jobs:
cp -r bin dist
cp -r examples dist
- name: Upload artifact
uses: actions/upload-artifact@v1
uses: actions/upload-artifact@v4
with:
include-hidden-files: true
name: windows_artifacts
path: dist
build_ubuntu:
name: Ubuntu Build
build_linux:
name: Linux Build
if: github.repository == 'odin-lang/Odin'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- name: (Linux) Download LLVM
- uses: actions/checkout@v4
- name: (Linux) Download LLVM and Build Odin
run: |
wget https://apt.llvm.org/llvm.sh
chmod +x llvm.sh
sudo ./llvm.sh 17
echo "/usr/lib/llvm-17/bin" >> $GITHUB_PATH
- name: build odin
run: make nightly
docker run --rm -v "$PWD:/src" -w /src alpine sh -c '
apk add --no-cache \
musl-dev llvm20-dev clang20 git mold lz4 \
libxml2-static llvm20-static zlib-static zstd-static \
make &&
./ci/build_linux_static.sh
'
- name: Odin run
run: ./odin run examples/demo
- name: Copy artifacts
run: |
mkdir dist
cp odin dist
cp LICENSE dist
cp libLLVM* dist
cp -r shared dist
cp -r base dist
cp -r core dist
cp -r vendor dist
cp -r examples dist
# Zipping so executable permissions are retained, see https://github.com/actions/upload-artifact/issues/38
zip -r dist.zip dist
FILE="odin-linux-amd64-nightly+$(date -I)"
mkdir $FILE
cp odin $FILE
cp LICENSE $FILE
cp -r shared $FILE
cp -r base $FILE
cp -r core $FILE
cp -r vendor $FILE
cp -r examples $FILE
./ci/remove_windows_binaries.sh $FILE
# Creating a tarball so executable permissions are retained, see https://github.com/actions/upload-artifact/issues/38
tar -czvf dist.tar.gz $FILE
- name: Odin run
run: |
FILE="odin-linux-amd64-nightly+$(date -I)"
$FILE/odin run examples/demo
- name: Upload artifact
uses: actions/upload-artifact@v1
uses: actions/upload-artifact@v4
with:
name: ubuntu_artifacts
path: dist.zip
name: linux_artifacts
path: dist.tar.gz
build_linux_arm:
name: Linux ARM Build
if: github.repository == 'odin-lang/Odin'
runs-on: ubuntu-24.04-arm
steps:
- uses: actions/checkout@v4
- name: (Linux ARM) Download LLVM and Build Odin
run: |
docker run --rm -v "$PWD:/src" -w /src arm64v8/alpine sh -c '
apk add --no-cache \
musl-dev llvm20-dev clang20 git mold lz4 \
libxml2-static llvm20-static zlib-static zstd-static \
make &&
./ci/build_linux_static.sh
'
- name: Odin run
run: ./odin run examples/demo
- name: Copy artifacts
run: |
FILE="odin-linux-arm64-nightly+$(date -I)"
mkdir $FILE
cp odin $FILE
cp LICENSE $FILE
cp -r shared $FILE
cp -r base $FILE
cp -r core $FILE
cp -r vendor $FILE
cp -r examples $FILE
./ci/remove_windows_binaries.sh $FILE
# Creating a tarball so executable permissions are retained, see https://github.com/actions/upload-artifact/issues/38
tar -czvf dist.tar.gz $FILE
- name: Odin run
run: |
FILE="odin-linux-arm64-nightly+$(date -I)"
$FILE/odin run examples/demo
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: linux_arm_artifacts
path: dist.tar.gz
build_macos:
name: MacOS Build
if: github.repository == 'odin-lang/Odin'
runs-on: macos-13
runs-on: macos-14 # Intel machine
steps:
- uses: actions/checkout@v1
- uses: actions/checkout@v4
- name: Download LLVM and setup PATH
run: |
brew install llvm@17 dylibbundler
echo "/usr/local/opt/llvm@17/bin" >> $GITHUB_PATH
brew update
brew install llvm@20 dylibbundler lld@20
- name: build odin
# These -L makes the linker prioritize system libraries over LLVM libraries, this is mainly to
# not link with libunwind bundled with LLVM but link with libunwind on the system.
run: CXXFLAGS="-L/usr/lib/system -L/usr/lib" make nightly
- name: Bundle
run: |
mkdir dist
cp odin dist
cp LICENSE dist
cp -r shared dist
cp -r base dist
cp -r core dist
cp -r vendor dist
cp -r examples dist
dylibbundler -b -x dist/odin -d dist/libs -od -p @executable_path/libs
# Zipping so executable permissions are retained, see https://github.com/actions/upload-artifact/issues/38
zip -r dist.zip dist
FILE="odin-macos-amd64-nightly+$(date -I)"
mkdir $FILE
cp odin $FILE
cp LICENSE $FILE
cp -r shared $FILE
cp -r base $FILE
cp -r core $FILE
cp -r vendor $FILE
cp -r examples $FILE
./ci/remove_windows_binaries.sh $FILE
dylibbundler -b -x $FILE/odin -d $FILE/libs -od -p @executable_path/libs
# Creating a tarball so executable permissions are retained, see https://github.com/actions/upload-artifact/issues/38
tar -czvf dist.tar.gz $FILE
- name: Odin run
run: ./dist/odin run examples/demo
run: |
FILE="odin-macos-amd64-nightly+$(date -I)"
$FILE/odin run examples/demo
- name: Upload artifact
uses: actions/upload-artifact@v1
uses: actions/upload-artifact@v4
with:
name: macos_artifacts
path: dist.zip
path: dist.tar.gz
build_macos_arm:
name: MacOS ARM Build
if: github.repository == 'odin-lang/Odin'
runs-on: macos-14 # ARM machine
steps:
- uses: actions/checkout@v1
- uses: actions/checkout@v4
- name: Download LLVM and setup PATH
run: |
brew install llvm@17 dylibbundler
echo "/opt/homebrew/opt/llvm@17/bin" >> $GITHUB_PATH
brew update
brew install llvm@20 dylibbundler lld@20
- name: build odin
# These -L makes the linker prioritize system libraries over LLVM libraries, this is mainly to
# not link with libunwind bundled with LLVM but link with libunwind on the system.
run: CXXFLAGS="-L/usr/lib/system -L/usr/lib" make nightly
- name: Bundle
run: |
mkdir dist
cp odin dist
cp LICENSE dist
cp -r shared dist
cp -r base dist
cp -r core dist
cp -r vendor dist
cp -r examples dist
dylibbundler -b -x dist/odin -d dist/libs -od -p @executable_path/libs
# Zipping so executable permissions are retained, see https://github.com/actions/upload-artifact/issues/38
zip -r dist.zip dist
FILE="odin-macos-arm64-nightly+$(date -I)"
mkdir $FILE
cp odin $FILE
cp LICENSE $FILE
cp -r shared $FILE
cp -r base $FILE
cp -r core $FILE
cp -r vendor $FILE
cp -r examples $FILE
./ci/remove_windows_binaries.sh $FILE
dylibbundler -b -x $FILE/odin -d $FILE/libs -od -p @executable_path/libs
# Creating a tarball so executable permissions are retained, see https://github.com/actions/upload-artifact/issues/38
tar -czvf dist.tar.gz $FILE
- name: Odin run
run: ./dist/odin run examples/demo
run: |
FILE="odin-macos-arm64-nightly+$(date -I)"
$FILE/odin run examples/demo
- name: Upload artifact
uses: actions/upload-artifact@v1
uses: actions/upload-artifact@v4
with:
name: macos_arm_artifacts
path: dist.zip
path: dist.tar.gz
upload_b2:
runs-on: [ubuntu-latest]
needs: [build_windows, build_macos, build_macos_arm, build_ubuntu]
needs: [build_windows, build_macos, build_macos_arm, build_linux, build_linux_arm]
steps:
- uses: actions/checkout@v1
- uses: actions/setup-python@v2
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: '3.8.x'
- name: Install B2 CLI
- name: Install B2 SDK
shell: bash
run: |
python -m pip install --upgrade pip
pip install --upgrade b2
pip install --upgrade b2sdk
- name: Display Python version
run: python -c "import sys; print(sys.version)"
- name: Download Windows artifacts
uses: actions/download-artifact@v1
uses: actions/download-artifact@v4.1.7
with:
name: windows_artifacts
path: windows_artifacts
- name: Download Ubuntu artifacts
uses: actions/download-artifact@v1
uses: actions/download-artifact@v4.1.7
with:
name: ubuntu_artifacts
name: linux_artifacts
path: linux_artifacts
- name: Download Ubuntu ARM artifacts
uses: actions/download-artifact@v4.1.7
with:
name: linux_arm_artifacts
path: linux_arm_artifacts
- name: Download macOS artifacts
uses: actions/download-artifact@v1
uses: actions/download-artifact@v4.1.7
with:
name: macos_artifacts
path: macos_artifacts
- name: Download macOS arm artifacts
uses: actions/download-artifact@v1
uses: actions/download-artifact@v4.1.7
with:
name: macos_arm_artifacts
path: macos_arm_artifacts
- name: Debug
run: |
tree -L 2
- name: Create archives and upload
shell: bash
@@ -188,24 +260,11 @@ jobs:
BUCKET: ${{ secrets.B2_BUCKET }}
DAYS_TO_KEEP: ${{ secrets.B2_DAYS_TO_KEEP }}
run: |
echo Authorizing B2 account
b2 account authorize "$APPID" "$APPKEY"
echo Uploading artifcates to B2
chmod +x ./ci/upload_create_nightly.sh
./ci/upload_create_nightly.sh "$BUCKET" windows-amd64 windows_artifacts/
./ci/upload_create_nightly.sh "$BUCKET" ubuntu-amd64 ubuntu_artifacts/dist.zip
./ci/upload_create_nightly.sh "$BUCKET" macos-amd64 macos_artifacts/dist.zip
./ci/upload_create_nightly.sh "$BUCKET" macos-arm64 macos_arm_artifacts/dist.zip
echo Deleting old artifacts in B2
python3 ci/delete_old_binaries.py "$BUCKET" "$DAYS_TO_KEEP"
echo Creating nightly.json
python3 ci/create_nightly_json.py "$BUCKET" > nightly.json
echo Uploading nightly.json
b2 upload-file "$BUCKET" nightly.json nightly.json
echo Clear B2 account info
b2 clear-account
file linux_artifacts/dist.tar.gz
python3 ci/nightly.py artifact windows-amd64 windows_artifacts/
python3 ci/nightly.py artifact linux-amd64 linux_artifacts/dist.tar.gz
python3 ci/nightly.py artifact linux-arm64 linux_arm_artifacts/dist.tar.gz
python3 ci/nightly.py artifact macos-amd64 macos_artifacts/dist.tar.gz
python3 ci/nightly.py artifact macos-arm64 macos_arm_artifacts/dist.tar.gz
python3 ci/nightly.py prune
python3 ci/nightly.py json
+20 -36
View File
@@ -17,45 +17,12 @@
[Rr]eleases/
x64/
x86/
!/core/simd/x86
bld/
[Bb]in/
[Oo]bj/
[Ll]og/
![Cc]ore/[Ll]og/
tests/documentation/verify/
tests/documentation/all.odin-doc
tests/internal/test_map
tests/internal/test_pow
tests/internal/test_rtti
tests/core/test_base64
tests/core/test_cbor
tests/core/test_core_compress
tests/core/test_core_container
tests/core/test_core_filepath
tests/core/test_core_fmt
tests/core/test_core_i18n
tests/core/test_core_image
tests/core/test_core_libc
tests/core/test_core_match
tests/core/test_core_math
tests/core/test_core_net
tests/core/test_core_os_exit
tests/core/test_core_reflect
tests/core/test_core_strings
tests/core/test_core_time
tests/core/test_crypto
tests/core/test_hash
tests/core/test_hex
tests/core/test_hxa
tests/core/test_json
tests/core/test_linalg_glsl_math
tests/core/test_noise
tests/core/test_varint
tests/core/test_xml
tests/core/test_core_slice
tests/core/test_core_thread
tests/core/test_core_runtime
tests/vendor/vendor_botan
# Visual Studio 2015 cache/options directory
.vs/
# Visual Studio Code options directory
@@ -299,14 +266,18 @@ bin/
*.exe
*.obj
*.pdb
*.res
desktop.ini
Thumbs.db
# - Linux/MacOS
odin
!odin/
odin.dSYM
**/*.dSYM
*.bin
demo.bin
libLLVM*.so*
*.a
# shared collection
shared/
@@ -323,5 +294,18 @@ build.sh
# RAD debugger project file
*.raddbg
*.rdi
tests/issues/build/*
misc/featuregen/featuregen
codegen/build/gen_src.map
# Clangd stuff
.cache/
.clangd
compile_commands.json
# Dev cmake helpers
build/
cmake-build*/
CMakeLists.txt
sandbox/
+14 -23
View File
@@ -1,26 +1,17 @@
Copyright (c) 2016-2024 Ginger Bill. All rights reserved.
Copyright (c) 2016-2025 Ginger Bill. All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
arising from the use of this software.
1. Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it
freely, subject to the following restrictions:
2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
3. Neither the name of the copyright holder nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
1. The origin of this software must not be misrepresented; you must not
claim that you wrote the original software. If you use this software
in a product, an acknowledgment in the product documentation would be
appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
BIN
View File
Binary file not shown.
+7 -1
View File
@@ -1,4 +1,4 @@
all: debug
all: default
demo:
./odin run examples/demo/demo.odin -file
@@ -6,12 +6,18 @@ demo:
report:
./odin report
default:
PROGRAM=make ./build_odin.sh # debug
debug:
./build_odin.sh debug
release:
./build_odin.sh release
release-native:
./build_odin.sh release-native
release_native:
./build_odin.sh release-native
+36 -3
View File
@@ -1,3 +1,32 @@
# Sectr Fork
This is a fork of the compiler intended for usage with [SectrPrototype](https://github.com/Ed94/SectrPrototype)
There were additions made for quality of life reasons:
* I added support for 'monlithic packages' or 'uniform-across-subdirectories packages'. It allows me to organize the main package with sub-directories. (Could be flag instead but making it a file flag works well)
* Added the ability to debug using statements on structs (fields get dumped to the stack as ptr refs)
* They show up as `struct_name::field_name`
* Remove implicit assignments for container allocators in the Base and Core packages
* I did not enjoy bug hunting a memory corruption because I mistakenly didn't properly initialize a core container with their designated initiatizer: new, make, or init.
* Affects the following:
* base:runtime/core_builtin.doin:`_reserve_dynamic_array`, `_resize_dynamic_array`, `_shrink_dynamic_array`
* base:runtime/core_builtin_soa.odin:`make_soa_aligned`, `_reserve_soa`
* base:runtime/default_temp_allocator_arena.odin:`arena_alloc`
* base:runtime/dynamic_array_internal.odin:`__dynamic_array_reserve`, `__dynamic_array_shrink`
* base:runtime/dynamic_map_internal.odin:`map_reserve_dynamic`, `map_shrink_dynamic`
* core:flags/internal_assignment.doin:`set_key_value`
* core:mem/tracking_allocator.odin:`tracking_allocator_proc`
* core:strings/intern.odin:`_intern_get_entry`
* Added debug breaks to the following:
* core:cbor/unmarshal.odin:`_unmarshal_map`
* core:json/unmarshal.odin:`unmarshal_object`
* ~~Added #region, #endregion directives support for editors.~~ Removed in favor of using an editor extension/plugin to enable folding via comment region signatures.
A [fork of the ols language server](https://github.com/Ed94/ols) has also be made to support these adjustments.
---
<p align="center">
<img src="misc/logo-slim.png" alt="Odin logo" style="width:65%">
<br/>
@@ -15,7 +44,7 @@
<img src="https://img.shields.io/discord/568138951836172421?logo=discord">
</a>
<a href="https://github.com/odin-lang/odin/actions">
<img src="https://github.com/odin-lang/odin/workflows/CI/badge.svg?branch=master&event=push">
<img src="https://github.com/odin-lang/odin/actions/workflows/ci.yml/badge.svg?branch=master&event=push">
</a>
</p>
@@ -76,9 +105,13 @@ Answers to common questions about Odin.
Documentation for all the official packages part of the [core](https://pkg.odin-lang.org/core/) and [vendor](https://pkg.odin-lang.org/vendor/) library collections.
#### [The Odin Wiki](https://github.com/odin-lang/Odin/wiki)
#### [Examples](https://github.com/odin-lang/examples)
A wiki maintained by the Odin community.
Examples on how to write idiomatic Odin code. Shows how to accomplish specific tasks in Odin, as well as how to use packages from `core` and `vendor`.
#### [Odin Documentation](https://odin-lang.org/docs/)
Documentation for the Odin language itself.
#### [Odin Discord](https://discord.gg/sVBPHEv)
+233 -8
View File
@@ -1,17 +1,238 @@
// This is purely for documentation
package builtin
import "base:runtime"
nil :: nil
false :: 0!=0
true :: 0==0
ODIN_OS :: ODIN_OS
ODIN_ARCH :: ODIN_ARCH
ODIN_ENDIAN :: ODIN_ENDIAN
ODIN_VENDOR :: ODIN_VENDOR
ODIN_VERSION :: ODIN_VERSION
ODIN_ROOT :: ODIN_ROOT
ODIN_DEBUG :: ODIN_DEBUG
// The following constants are added in `checker.cpp`'s `init_universal` procedure.
/*
An `enum` value indicating the target's CPU architecture.
Possible values are: `.amd64`, `.i386`, `.arm32`, `.arm64`, `.wasm32`, `.wasm64p32`, and `.riscv64`.
*/
ODIN_ARCH :: ODIN_ARCH
/*
A `string` indicating the target's CPU architecture.
Possible values are: "amd64", "i386", "arm32", "arm64", "wasm32", "wasm64p32", "riscv64".
*/
ODIN_ARCH_STRING :: ODIN_ARCH_STRING
/*
An `enum` value indicating the type of compiled output, chosen using `-build-mode`.
Possible values are: `.Executable`, `.Dynamic`, `.Static`, `.Object`, `.Assembly`, and `.LLVM_IR`.
*/
ODIN_BUILD_MODE :: ODIN_BUILD_MODE
/*
A `string` containing the name of the folder that contains the entry point,
e.g. for `%ODIN_ROOT%/examples/demo`, this would contain `demo`.
*/
ODIN_BUILD_PROJECT_NAME :: ODIN_BUILD_PROJECT_NAME
/*
An `i64` containing the time at which the executable was compiled, in nanoseconds.
This is compatible with the `time.Time` type, i.e. `time.Time{_nsec=ODIN_COMPILE_TIMESTAMP}`
*/
ODIN_COMPILE_TIMESTAMP :: ODIN_COMPILE_TIMESTAMP
/*
`true` if the `-debug` command line switch is passed, which enables debug info generation.
*/
ODIN_DEBUG :: ODIN_DEBUG
/*
`true` if the `-default-to-nil-allocator` command line switch is passed,
which sets the initial `context.allocator` to an allocator that does nothing.
*/
ODIN_DEFAULT_TO_NIL_ALLOCATOR :: ODIN_DEFAULT_TO_NIL_ALLOCATOR
/*
`true` if the `-default-to-panic-allocator` command line switch is passed,
which sets the initial `context.allocator` to an allocator that panics if allocated from.
*/
ODIN_DEFAULT_TO_PANIC_ALLOCATOR :: ODIN_DEFAULT_TO_PANIC_ALLOCATOR
/*
`true` if the `-disable-assert` command line switch is passed,
which removes all calls to `assert` from the program.
*/
ODIN_DISABLE_ASSERT :: ODIN_DISABLE_ASSERT
/*
An `enum` value indicating the endianness of the target.
Possible values are: `.Little` and `.Big`.
*/
ODIN_ENDIAN :: ODIN_ENDIAN
/*
An `string` indicating the endianness of the target.
Possible values are: "little" and "big".
*/
ODIN_ENDIAN_STRING :: ODIN_ENDIAN_STRING
/*
An `enum` value set using the `-error-pos-style` switch, indicating the source location style used for compile errors and warnings.
Possible values are: `.Default` (Odin-style) and `.Unix`.
*/
ODIN_ERROR_POS_STYLE :: ODIN_ERROR_POS_STYLE
/*
`true` if the `-foreign-error-procedures` command line switch is passed,
which inhibits generation of runtime error procedures, so that they can be in a separate compilation unit.
*/
ODIN_FOREIGN_ERROR_PROCEDURES :: ODIN_FOREIGN_ERROR_PROCEDURES
/*
A `string` describing the microarchitecture used for code generation.
If not set using the `-microarch` command line switch, the compiler will pick a default.
Possible values include, but are not limited to: "sandybridge", "x86-64-v2".
*/
ODIN_MICROARCH_STRING :: ODIN_MICROARCH_STRING
/*
An `int` value representing the minimum OS version given to the linker, calculated as `major * 10_000 + minor * 100 + revision`.
If not set using the `-minimum-os-version` command line switch, it defaults to `0`, except on Darwin, where it's `11_00_00`.
*/
ODIN_MINIMUM_OS_VERSION :: ODIN_MINIMUM_OS_VERSION
/*
`true` if the `-no-bounds-check` command line switch is passed, which disables bounds checking at runtime.
*/
ODIN_NO_BOUNDS_CHECK :: ODIN_NO_BOUNDS_CHECK
/*
`true` if the `-no-crt` command line switch is passed, which inhibits linking with the C Runtime Library, a.k.a. LibC.
*/
ODIN_NO_CRT :: ODIN_NO_CRT
/*
`true` if the `-no-entry-point` command line switch is passed, which makes the declaration of a `main` procedure optional.
*/
ODIN_NO_ENTRY_POINT :: ODIN_NO_ENTRY_POINT
/*
`true` if the `-no-rtti` command line switch is passed, which inhibits generation of full Runtime Type Information.
*/
ODIN_NO_RTTI :: ODIN_NO_RTTI
/*
`true` if the `-no-type-assert` command line switch is passed, which disables type assertion checking program wide.
*/
ODIN_NO_TYPE_ASSERT :: ODIN_NO_TYPE_ASSERT
/*
An `enum` value indicating the optimization level selected using the `-o` command line switch.
Possible values are: `.None`, `.Minimal`, `.Size`, `.Speed`, and `.Aggressive`.
If `ODIN_OPTIMIZATION_MODE` is anything other than `.None` or `.Minimal`, the compiler will also perform a unity build,
and `ODIN_USE_SEPARATE_MODULES` will be set to `false` as a result.
*/
ODIN_OPTIMIZATION_MODE :: ODIN_OPTIMIZATION_MODE
/*
An `enum` value indicating what the target operating system is.
*/
ODIN_OS :: ODIN_OS
/*
A `string` indicating what the target operating system is.
*/
ODIN_OS_STRING :: ODIN_OS_STRING
/*
An `enum` value indicating the platform subtarget, chosen using the `-subtarget` switch.
Possible values are: `.Default` `.iPhone`, .iPhoneSimulator, and `.Android`.
*/
ODIN_PLATFORM_SUBTARGET :: ODIN_PLATFORM_SUBTARGET
/*
A `string` representing the path of the folder containing the Odin compiler,
relative to which we expect to find the `base` and `core` package collections.
*/
ODIN_ROOT :: ODIN_ROOT
/*
A `bit_set` indicating the sanitizer flags set using the `-sanitize` command line switch.
Supported flags are `.Address`, `.Memory`, and `.Thread`.
*/
ODIN_SANITIZER_FLAGS :: ODIN_SANITIZER_FLAGS
/*
`true` if the code is being compiled via an invocation of `odin test`.
*/
ODIN_TEST :: ODIN_TEST
/*
`true` if built using the experimental Tilde backend.
*/
ODIN_TILDE :: ODIN_TILDE
/*
`true` by default, meaning each each package is built into its own object file, and then linked together.
`false` if the `-use-single-module` command line switch to force a unity build is provided.
If `ODIN_OPTIMIZATION_MODE` is anything other than `.None` or `.Minimal`, the compiler will also perform a unity build,
and this constant will also be set to `false`.
*/
ODIN_USE_SEPARATE_MODULES :: ODIN_USE_SEPARATE_MODULES
/*
`true` if Valgrind integration is supported on the target.
*/
ODIN_VALGRIND_SUPPORT :: ODIN_VALGRIND_SUPPORT
/*
A `string` which identifies the compiler being used. The official compiler sets this to `"odin"`.
*/
ODIN_VENDOR :: ODIN_VENDOR
/*
A `string` containing the version of the Odin compiler, typically in the format `dev-YYYY-MM`.
*/
ODIN_VERSION :: ODIN_VERSION
/*
A `string` containing the Git hash part of the Odin version.
Empty if `.git` could not be detected at the time the compiler was built.
*/
ODIN_VERSION_HASH :: ODIN_VERSION_HASH
/*
An `enum` set by the `-subsystem` flag, specifying which Windows subsystem the PE file was created for.
Possible values are:
`.Unknown` - Default and only value on non-Windows platforms
`.Console` - Default on Windows
`.Windows` - Can be used by graphical applications so Windows doesn't open an empty console
There are some other possible values for e.g. EFI applications, but only Console and Windows are supported.
See also: https://learn.microsoft.com/en-us/windows/win32/api/winnt/ns-winnt-image_optional_header64
*/
ODIN_WINDOWS_SUBSYSTEM :: ODIN_WINDOWS_SUBSYSTEM
/*
An `string` set by the `-subsystem` flag, specifying which Windows subsystem the PE file was created for.
Possible values are:
"UNKNOWN" - Default and only value on non-Windows platforms
"CONSOLE" - Default on Windows
"WINDOWS" - Can be used by graphical applications so Windows doesn't open an empty console
There are some other possible values for e.g. EFI applications, but only Console and Windows are supported.
See also: https://learn.microsoft.com/en-us/windows/win32/api/winnt/ns-winnt-image_optional_header64
*/
ODIN_WINDOWS_SUBSYSTEM_STRING :: ODIN_WINDOWS_SUBSYSTEM_STRING
/*
`true` if LLVM supports the f16 type.
*/
__ODIN_LLVM_F16_SUPPORTED :: __ODIN_LLVM_F16_SUPPORTED
byte :: u8 // alias
@@ -117,7 +338,8 @@ jmag :: proc(value: Quaternion) -> Float ---
kmag :: proc(value: Quaternion) -> Float ---
conj :: proc(value: Complex_Or_Quaternion) -> Complex_Or_Quaternion ---
expand_values :: proc(value: Struct_Or_Array) -> (A, B, C, ...) ---
expand_values :: proc(value: Struct_Or_Array) -> (A, B, C, ...) ---
compress_values :: proc(values: ...) -> Struct_Or_Array_Like_Type ---
min :: proc(values: ..T) -> T ---
max :: proc(values: ..T) -> T ---
@@ -128,3 +350,6 @@ soa_zip :: proc(slices: ...) -> #soa[]Struct ---
soa_unzip :: proc(value: $S/#soa[]$E) -> (slices: ...) ---
unreachable :: proc() -> ! ---
// Where T is a string, slice, dynamic array, or pointer to an array type
raw_data :: proc(t: $T) -> rawptr
+96 -25
View File
@@ -1,7 +1,9 @@
// This is purely for documentation
//+build ignore
#+build ignore
package intrinsics
import "base:runtime"
// Package-Related
is_package_imported :: proc(package_name: string) -> bool ---
@@ -30,6 +32,7 @@ trap :: proc() -> ! ---
alloca :: proc(size, align: int) -> [^]u8 ---
cpu_relax :: proc() ---
read_cycle_counter :: proc() -> i64 ---
read_cycle_counter_frequency :: proc() -> i64 ---
count_ones :: proc(x: $T) -> T where type_is_integer(T) || type_is_simd_vector(T) ---
count_zeros :: proc(x: $T) -> T where type_is_integer(T) || type_is_simd_vector(T) ---
@@ -38,9 +41,12 @@ count_leading_zeros :: proc(x: $T) -> T where type_is_integer(T) || type_is_sim
reverse_bits :: proc(x: $T) -> T where type_is_integer(T) || type_is_simd_vector(T) ---
byte_swap :: proc(x: $T) -> T where type_is_integer(T) || type_is_float(T) ---
overflow_add :: proc(lhs, rhs: $T) -> (T, bool) ---
overflow_sub :: proc(lhs, rhs: $T) -> (T, bool) ---
overflow_mul :: proc(lhs, rhs: $T) -> (T, bool) ---
overflow_add :: proc(lhs, rhs: $T) -> (T, bool) where type_is_integer(T) #optional_ok ---
overflow_sub :: proc(lhs, rhs: $T) -> (T, bool) where type_is_integer(T) #optional_ok ---
overflow_mul :: proc(lhs, rhs: $T) -> (T, bool) where type_is_integer(T) #optional_ok ---
saturating_add :: proc(lhs, rhs: $T) -> T where type_is_integer(T) ---
saturating_sub :: proc(lhs, rhs: $T) -> T where type_is_integer(T) ---
sqrt :: proc(x: $T) -> T where type_is_float(T) || (type_is_simd_vector(T) && type_is_float(type_elem_type(T))) ---
@@ -69,10 +75,12 @@ prefetch_write_instruction :: proc(address: rawptr, #const locality: i32 /* 0..=
prefetch_write_data :: proc(address: rawptr, #const locality: i32 /* 0..=3 */) ---
// Compiler Hints
expect :: proc(val, expected_val: T) -> T ---
expect :: proc(val, expected_val: $T) -> T ---
// Linux and Darwin Only
syscall :: proc(id: uintptr, args: ..uintptr) -> uintptr ---
// FreeBSD, NetBSD, et cetera
syscall_bsd :: proc(id: uintptr, args: ..uintptr) -> (uintptr, bool) ---
// Atomics
@@ -130,9 +138,13 @@ type_is_rune :: proc($T: typeid) -> bool ---
type_is_float :: proc($T: typeid) -> bool ---
type_is_complex :: proc($T: typeid) -> bool ---
type_is_quaternion :: proc($T: typeid) -> bool ---
type_is_string :: proc($T: typeid) -> bool ---
type_is_typeid :: proc($T: typeid) -> bool ---
type_is_any :: proc($T: typeid) -> bool ---
type_is_string :: proc($T: typeid) -> bool ---
type_is_string16 :: proc($T: typeid) -> bool ---
type_is_cstring :: proc($T: typeid) -> bool ---
type_is_cstring16 :: proc($T: typeid) -> bool ---
type_is_endian_platform :: proc($T: typeid) -> bool ---
type_is_endian_little :: proc($T: typeid) -> bool ---
@@ -145,6 +157,7 @@ type_is_indexable :: proc($T: typeid) -> bool ---
type_is_sliceable :: proc($T: typeid) -> bool ---
type_is_comparable :: proc($T: typeid) -> bool ---
type_is_simple_compare :: proc($T: typeid) -> bool --- // easily compared using memcmp (== and !=)
type_is_nearly_simple_compare :: proc($T: typeid) -> bool --- // easily compared using memcmp (including floats)
type_is_dereferenceable :: proc($T: typeid) -> bool ---
type_is_valid_map_key :: proc($T: typeid) -> bool ---
type_is_valid_matrix_elements :: proc($T: typeid) -> bool ---
@@ -162,6 +175,7 @@ type_is_union :: proc($T: typeid) -> bool ---
type_is_enum :: proc($T: typeid) -> bool ---
type_is_proc :: proc($T: typeid) -> bool ---
type_is_bit_set :: proc($T: typeid) -> bool ---
type_is_bit_field :: proc($T: typeid) -> bool ---
type_is_simd_vector :: proc($T: typeid) -> bool ---
type_is_matrix :: proc($T: typeid) -> bool ---
@@ -192,7 +206,8 @@ type_proc_return_count :: proc($T: typeid) -> int where type_is_proc(T) ---
type_proc_parameter_type :: proc($T: typeid, index: int) -> typeid where type_is_proc(T) ---
type_proc_return_type :: proc($T: typeid, index: int) -> typeid where type_is_proc(T) ---
type_struct_field_count :: proc($T: typeid) -> int where type_is_struct(T) ---
type_struct_field_count :: proc($T: typeid) -> int where type_is_struct(T) ---
type_struct_has_implicit_padding :: proc($T: typeid) -> bool where type_is_struct(T) ---
type_polymorphic_record_parameter_count :: proc($T: typeid) -> typeid ---
type_polymorphic_record_parameter_value :: proc($T: typeid, index: int) -> $V ---
@@ -204,6 +219,10 @@ type_is_subtype_of :: proc($T, $U: typeid) -> bool ---
type_field_index_of :: proc($T: typeid, $name: string) -> uintptr ---
// "Contiguous" means that the set of enum constants, when sorted, have a difference of either 0 or 1 between consecutive values.
// This is the exact opposite of "sparse".
type_enum_is_contiguous :: proc($T: typeid) -> bool where type_is_enum(T) ---
type_equal_proc :: proc($T: typeid) -> (equal: proc "contextless" (rawptr, rawptr) -> bool) where type_is_comparable(T) ---
type_hasher_proc :: proc($T: typeid) -> (hasher: proc "contextless" (data: rawptr, seed: uintptr) -> uintptr) where type_is_comparable(T) ---
@@ -213,14 +232,32 @@ type_map_cell_info :: proc($T: typeid) -> ^runtime.Map_Cell_Info ---
type_convert_variants_to_pointers :: proc($T: typeid) -> typeid where type_is_union(T) ---
type_merge :: proc($U, $V: typeid) -> typeid where type_is_union(U), type_is_union(V) ---
type_integer_to_unsigned :: proc($T: typeid) -> type where type_is_integer(T), !type_is_unsigned(T) ---
type_integer_to_signed :: proc($T: typeid) -> type where type_is_integer(T), type_is_unsigned(T) ---
type_has_shared_fields :: proc($U, $V: typeid) -> bool where type_is_struct(U), type_is_struct(V) ---
// Returns the canonicalized name of the type, of which is used to produce the pseudo-unique 'typeid'
type_canonical_name :: proc($T: typeid) -> string ---
constant_utf16_cstring :: proc($literal: string) -> [^]u16 ---
constant_log2 :: proc($v: $T) -> T where type_is_integer(T) ---
constant_floor :: proc($v: $T) -> T where type_is_integer(T) || type_is_float(T) ---
constant_trunc :: proc($v: $T) -> T where type_is_integer(T) || type_is_float(T) ---
constant_ceil :: proc($v: $T) -> T where type_is_integer(T) || type_is_float(T) ---
constant_round :: proc($v: $T) -> T where type_is_integer(T) || type_is_float(T) ---
// SIMD related
simd_add :: proc(a, b: #simd[N]T) -> #simd[N]T ---
simd_sub :: proc(a, b: #simd[N]T) -> #simd[N]T ---
simd_mul :: proc(a, b: #simd[N]T) -> #simd[N]T ---
simd_div :: proc(a, b: #simd[N]T) -> #simd[N]T where type_is_float(T) ---
simd_saturating_add :: proc(a, b: #simd[N]T) -> #simd[N]T where type_is_integer(T) ---
simd_saturating_sub :: proc(a, b: #simd[N]T) -> #simd[N]T where type_is_integer(T) ---
// Keeps Odin's Behaviour
// (x << y) if y <= mask else 0
simd_shl :: proc(a: #simd[N]T, b: #simd[N]Unsigned_Integer) -> #simd[N]T ---
@@ -231,9 +268,6 @@ simd_shr :: proc(a: #simd[N]T, b: #simd[N]Unsigned_Integer) -> #simd[N]T ---
simd_shl_masked :: proc(a: #simd[N]T, b: #simd[N]Unsigned_Integer) -> #simd[N]T ---
simd_shr_masked :: proc(a: #simd[N]T, b: #simd[N]Unsigned_Integer) -> #simd[N]T ---
simd_add_sat :: proc(a, b: #simd[N]T) -> #simd[N]T ---
simd_sub_sat :: proc(a, b: #simd[N]T) -> #simd[N]T ---
simd_bit_and :: proc(a, b: #simd[N]T) -> #simd[N]T ---
simd_bit_or :: proc(a, b: #simd[N]T) -> #simd[N]T ---
simd_bit_xor :: proc(a, b: #simd[N]T) -> #simd[N]T ---
@@ -262,16 +296,39 @@ simd_lanes_ge :: proc(a, b: #simd[N]T) -> #simd[N]Integer ---
simd_extract :: proc(a: #simd[N]T, idx: uint) -> T ---
simd_replace :: proc(a: #simd[N]T, idx: uint, elem: T) -> #simd[N]T ---
simd_reduce_add_ordered :: proc(a: #simd[N]T) -> T ---
simd_reduce_mul_ordered :: proc(a: #simd[N]T) -> T ---
simd_reduce_min :: proc(a: #simd[N]T) -> T ---
simd_reduce_max :: proc(a: #simd[N]T) -> T ---
simd_reduce_and :: proc(a: #simd[N]T) -> T ---
simd_reduce_or :: proc(a: #simd[N]T) -> T ---
simd_reduce_xor :: proc(a: #simd[N]T) -> T ---
simd_reduce_add_bisect :: proc(a: #simd[N]T) -> T where type_is_integer(T) || type_is_float(T)---
simd_reduce_mul_bisect :: proc(a: #simd[N]T) -> T where type_is_integer(T) || type_is_float(T)---
simd_reduce_add_ordered :: proc(a: #simd[N]T) -> T where type_is_integer(T) || type_is_float(T)---
simd_reduce_mul_ordered :: proc(a: #simd[N]T) -> T where type_is_integer(T) || type_is_float(T)---
simd_reduce_add_pairs :: proc(a: #simd[N]T) -> T where type_is_integer(T) || type_is_float(T)---
simd_reduce_mul_pairs :: proc(a: #simd[N]T) -> T where type_is_integer(T) || type_is_float(T)---
simd_reduce_min :: proc(a: #simd[N]T) -> T where type_is_integer(T) || type_is_float(T)---
simd_reduce_max :: proc(a: #simd[N]T) -> T where type_is_integer(T) || type_is_float(T)---
simd_reduce_and :: proc(a: #simd[N]T) -> T where type_is_integer(T) || type_is_float(T)---
simd_reduce_or :: proc(a: #simd[N]T) -> T where type_is_integer(T) || type_is_float(T)---
simd_reduce_xor :: proc(a: #simd[N]T) -> T where type_is_integer(T) || type_is_float(T)---
simd_reduce_any :: proc(a: #simd[N]T) -> T where type_is_boolean(T) ---
simd_reduce_all :: proc(a: #simd[N]T) -> T where type_is_boolean(T) ---
simd_extract_lsbs :: proc(a: #simd[N]T) -> bit_set[0..<N] where type_is_integer(T) || type_is_boolean(T) ---
simd_extract_msbs :: proc(a: #simd[N]T) -> bit_set[0..<N] where type_is_integer(T) || type_is_boolean(T) ---
simd_gather :: proc(ptr: #simd[N]rawptr, val: #simd[N]T, mask: #simd[N]U) -> #simd[N]T where type_is_integer(U) || type_is_boolean(U) ---
simd_scatter :: proc(ptr: #simd[N]rawptr, val: #simd[N]T, mask: #simd[N]U) where type_is_integer(U) || type_is_boolean(U) ---
simd_masked_load :: proc(ptr: rawptr, val: #simd[N]T, mask: #simd[N]U) -> #simd[N]T where type_is_integer(U) || type_is_boolean(U) ---
simd_masked_store :: proc(ptr: rawptr, val: #simd[N]T, mask: #simd[N]U) where type_is_integer(U) || type_is_boolean(U) ---
simd_masked_expand_load :: proc(ptr: rawptr, val: #simd[N]T, mask: #simd[N]U) -> #simd[N]T where type_is_integer(U) || type_is_boolean(U) ---
simd_masked_compress_store :: proc(ptr: rawptr, val: #simd[N]T, mask: #simd[N]U) where type_is_integer(U) || type_is_boolean(U) ---
simd_indices :: proc($T: typeid/#simd[$N]$E) -> T where type_is_numeric(T) ---
simd_shuffle :: proc(a, b: #simd[N]T, indices: ..int) -> #simd[len(indices)]T ---
simd_select :: proc(cond: #simd[N]boolean_or_integer, true, false: #simd[N]T) -> #simd[N]T ---
simd_runtime_swizzle :: proc(table: #simd[N]T, indices: #simd[N]T) -> #simd[N]T where type_is_integer(T) ---
// Lane-wise operations
simd_ceil :: proc(a: #simd[N]any_float) -> #simd[N]any_float ---
@@ -282,11 +339,11 @@ simd_nearest :: proc(a: #simd[N]any_float) -> #simd[N]any_float ---
simd_to_bits :: proc(v: #simd[N]T) -> #simd[N]Integer where size_of(T) == size_of(Integer), type_is_unsigned(Integer) ---
// equivalent a swizzle with descending indices, e.g. reserve(a, 3, 2, 1, 0)
simd_reverse :: proc(a: #simd[N]T) -> #simd[N]T ---
// equivalent to a swizzle with descending indices, e.g. reserve(a, 3, 2, 1, 0)
simd_lanes_reverse :: proc(a: #simd[N]T) -> #simd[N]T ---
simd_rotate_left :: proc(a: #simd[N]T, $offset: int) -> #simd[N]T ---
simd_rotate_right :: proc(a: #simd[N]T, $offset: int) -> #simd[N]T ---
simd_lanes_rotate_left :: proc(a: #simd[N]T, $offset: int) -> #simd[N]T ---
simd_lanes_rotate_right :: proc(a: #simd[N]T, $offset: int) -> #simd[N]T ---
// Checks if the current target supports the given target features.
//
@@ -295,6 +352,13 @@ simd_rotate_right :: proc(a: #simd[N]T, $offset: int) -> #simd[N]T ---
// if all listed features are supported.
has_target_feature :: proc($test: $T) -> bool where type_is_string(T) || type_is_proc(T) ---
// Utility Calls
concatentate :: proc(x, y: $T, z: ..T) -> T where type_is_array(T) || type_is_slice(T) ---
// Returns the value of the procedure where `x` must be a call expression
procedure_of :: proc(x: $T) -> T where type_is_proc(T) ---
// WASM targets only
wasm_memory_grow :: proc(index, delta: uintptr) -> int ---
wasm_memory_size :: proc(index: uintptr) -> int ---
@@ -315,19 +379,26 @@ x86_cpuid :: proc(ax, cx: u32) -> (eax, ebx, ecx, edx: u32) ---
x86_xgetbv :: proc(cx: u32) -> (eax, edx: u32) ---
// Darwin targets only
objc_object :: struct{}
objc_selector :: struct{}
objc_class :: struct{}
objc_id :: ^objc_object
objc_SEL :: ^objc_selector
objc_Class :: ^objc_class
objc_ivar :: struct{}
objc_id :: ^objc_object
objc_SEL :: ^objc_selector
objc_Class :: ^objc_class
objc_Ivar :: ^objc_ivar
objc_instancetype :: distinct objc_id
objc_find_selector :: proc($name: string) -> objc_SEL ---
objc_register_selector :: proc($name: string) -> objc_SEL ---
objc_find_class :: proc($name: string) -> objc_Class ---
objc_register_class :: proc($name: string) -> objc_Class ---
objc_ivar_get :: proc(self: ^$T) -> ^$U ---
objc_block :: proc(invoke: $T, ..any) -> ^Objc_Block(T) where type_is_proc(T) ---
objc_super :: proc(obj: ^$T) -> ^$U where type_is_subtype_of(T, objc_object) && type_is_subtype_of(U, objc_object) ---
valgrind_client_request :: proc(default: uintptr, request: uintptr, a0, a1, a2, a3, a4: uintptr) -> uintptr ---
+182 -88
View File
@@ -15,10 +15,10 @@
//
// IMPORTANT NOTE(bill): `type_info_of` cannot be used within a
// #shared_global_scope due to the internals of the compiler.
// This could change at a later date if the all these data structures are
// This could change at a later date if all these data structures are
// implemented within the compiler rather than in this "preload" file
//
//+no-instrumentation
#+no-instrumentation
package runtime
import "base:intrinsics"
@@ -61,19 +61,24 @@ Type_Info_Struct_Soa_Kind :: enum u8 {
Dynamic = 3,
}
Type_Info_String_Encoding_Kind :: enum u8 {
UTF_8 = 0,
UTF_16 = 1,
}
// Variant Types
Type_Info_Named :: struct {
name: string,
base: ^Type_Info,
pkg: string,
loc: Source_Code_Location,
loc: ^Source_Code_Location,
}
Type_Info_Integer :: struct {signed: bool, endianness: Platform_Endianness}
Type_Info_Rune :: struct {}
Type_Info_Float :: struct {endianness: Platform_Endianness}
Type_Info_Complex :: struct {}
Type_Info_Quaternion :: struct {}
Type_Info_String :: struct {is_cstring: bool}
Type_Info_String :: struct {is_cstring: bool, encoding: Type_Info_String_Encoding_Kind}
Type_Info_Boolean :: struct {}
Type_Info_Any :: struct {}
Type_Info_Type_Id :: struct {}
@@ -110,25 +115,33 @@ Type_Info_Parameters :: struct { // Only used for procedures parameters and resu
types: []^Type_Info,
names: []string,
}
Type_Info_Tuple :: Type_Info_Parameters // Will be removed eventually
Type_Info_Struct_Flags :: distinct bit_set[Type_Info_Struct_Flag; u8]
Type_Info_Struct_Flag :: enum u8 {
packed = 0,
raw_union = 1,
_ = 2,
align = 3,
}
Type_Info_Struct :: struct {
types: []^Type_Info,
names: []string,
offsets: []uintptr,
usings: []bool,
tags: []string,
is_packed: bool,
is_raw_union: bool,
is_no_copy: bool,
custom_align: bool,
// Slice these with `field_count`
types: [^]^Type_Info `fmt:"v,field_count"`,
names: [^]string `fmt:"v,field_count"`,
offsets: [^]uintptr `fmt:"v,field_count"`,
usings: [^]bool `fmt:"v,field_count"`,
tags: [^]string `fmt:"v,field_count"`,
equal: Equal_Proc, // set only when the struct has .Comparable set but does not have .Simple_Compare set
field_count: i32,
flags: Type_Info_Struct_Flags,
// These are only set iff this structure is an SOA structure
soa_kind: Type_Info_Struct_Soa_Kind,
soa_len: i32,
soa_base_type: ^Type_Info,
soa_len: int,
equal: Equal_Proc, // set only when the struct has .Comparable set but does not have .Simple_Compare set
}
Type_Info_Union :: struct {
variants: []^Type_Info,
@@ -142,9 +155,9 @@ Type_Info_Union :: struct {
shared_nil: bool,
}
Type_Info_Enum :: struct {
base: ^Type_Info,
names: []string,
values: []Type_Info_Enum_Value,
base: ^Type_Info,
names: []string,
values: []Type_Info_Enum_Value,
}
Type_Info_Map :: struct {
key: ^Type_Info,
@@ -162,14 +175,6 @@ Type_Info_Simd_Vector :: struct {
elem_size: int,
count: int,
}
Type_Info_Relative_Pointer :: struct {
pointer: ^Type_Info, // ^T
base_integer: ^Type_Info,
}
Type_Info_Relative_Multi_Pointer :: struct {
pointer: ^Type_Info, // [^]T
base_integer: ^Type_Info,
}
Type_Info_Matrix :: struct {
elem: ^Type_Info,
elem_size: int,
@@ -187,11 +192,12 @@ Type_Info_Soa_Pointer :: struct {
}
Type_Info_Bit_Field :: struct {
backing_type: ^Type_Info,
names: []string,
types: []^Type_Info,
bit_sizes: []uintptr,
bit_offsets: []uintptr,
tags: []string,
names: [^]string `fmt:"v,field_count"`,
types: [^]^Type_Info `fmt:"v,field_count"`,
bit_sizes: [^]uintptr `fmt:"v,field_count"`,
bit_offsets: [^]uintptr `fmt:"v,field_count"`,
tags: [^]string `fmt:"v,field_count"`,
field_count: int,
}
Type_Info_Flag :: enum u8 {
@@ -231,57 +237,12 @@ Type_Info :: struct {
Type_Info_Map,
Type_Info_Bit_Set,
Type_Info_Simd_Vector,
Type_Info_Relative_Pointer,
Type_Info_Relative_Multi_Pointer,
Type_Info_Matrix,
Type_Info_Soa_Pointer,
Type_Info_Bit_Field,
},
}
// NOTE(bill): This must match the compiler's
Typeid_Kind :: enum u8 {
Invalid,
Integer,
Rune,
Float,
Complex,
Quaternion,
String,
Boolean,
Any,
Type_Id,
Pointer,
Multi_Pointer,
Procedure,
Array,
Enumerated_Array,
Dynamic_Array,
Slice,
Tuple,
Struct,
Union,
Enum,
Map,
Bit_Set,
Simd_Vector,
Relative_Pointer,
Relative_Multi_Pointer,
Matrix,
Soa_Pointer,
Bit_Field,
}
#assert(len(Typeid_Kind) < 32)
Typeid_Bit_Field :: bit_field uintptr {
index: uintptr | 8*size_of(uintptr) - 8,
kind: Typeid_Kind | 5, // Typeid_Kind
named: bool | 1,
special: bool | 1, // signed, cstring, etc
reserved: bool | 1,
}
#assert(size_of(Typeid_Bit_Field) == size_of(uintptr))
// NOTE(bill): only the ones that are needed (not all types)
// This will be set by the compiler
type_table: []^Type_Info
@@ -299,6 +260,8 @@ when ODIN_OS == .Windows {
Thread_Detach = 3,
}
dll_forward_reason: DLL_Forward_Reason
dll_instance: rawptr
}
// IMPORTANT NOTE(bill): Must be in this order (as the compiler relies upon it)
@@ -397,11 +360,34 @@ Logger :: struct {
options: Logger_Options,
}
Random_Generator_Mode :: enum {
Read,
Reset,
Query_Info,
}
Random_Generator_Query_Info_Flag :: enum u32 {
Cryptographic,
Uniform,
External_Entropy,
Resettable,
}
Random_Generator_Query_Info :: distinct bit_set[Random_Generator_Query_Info_Flag; u32]
Random_Generator_Proc :: #type proc(data: rawptr, mode: Random_Generator_Mode, p: []byte)
Random_Generator :: struct {
procedure: Random_Generator_Proc,
data: rawptr,
}
Context :: struct {
allocator: Allocator,
temp_allocator: Allocator,
assertion_failure_proc: Assertion_Failure_Proc,
logger: Logger,
random_generator: Random_Generator,
user_ptr: rawptr,
user_index: int,
@@ -416,6 +402,11 @@ Raw_String :: struct {
len: int,
}
Raw_String16 :: struct {
data: [^]u16,
len: int,
}
Raw_Slice :: struct {
data: rawptr,
len: int,
@@ -460,10 +451,20 @@ Raw_Any :: struct {
data: rawptr,
id: typeid,
}
when !ODIN_NO_RTTI {
#assert(size_of(Raw_Any) == size_of(any))
}
Raw_Cstring :: struct {
data: [^]byte,
}
#assert(size_of(Raw_Cstring) == size_of(cstring))
Raw_Cstring16 :: struct {
data: [^]u16,
}
#assert(size_of(Raw_Cstring16) == size_of(cstring16))
Raw_Soa_Pointer :: struct {
data: rawptr,
@@ -490,11 +491,12 @@ Raw_Quaternion256_Vector_Scalar :: struct {vector: [3]f64, scalar: f64}
Linux,
Essence,
FreeBSD,
Haiku,
OpenBSD,
NetBSD,
Haiku,
WASI,
JS,
Orca,
Freestanding,
}
*/
@@ -510,10 +512,23 @@ Odin_OS_Type :: type_of(ODIN_OS)
arm64,
wasm32,
wasm64p32,
riscv64,
}
*/
Odin_Arch_Type :: type_of(ODIN_ARCH)
Odin_Arch_Types :: bit_set[Odin_Arch_Type]
ALL_ODIN_ARCH_TYPES :: Odin_Arch_Types{
.amd64,
.i386,
.arm32,
.arm64,
.wasm32,
.wasm64p32,
.riscv64,
}
/*
// Defined internally by the compiler
Odin_Build_Mode_Type :: enum int {
@@ -537,16 +552,39 @@ Odin_Build_Mode_Type :: type_of(ODIN_BUILD_MODE)
*/
Odin_Endian_Type :: type_of(ODIN_ENDIAN)
Odin_OS_Types :: bit_set[Odin_OS_Type]
ALL_ODIN_OS_TYPES :: Odin_OS_Types{
.Windows,
.Darwin,
.Linux,
.Essence,
.FreeBSD,
.OpenBSD,
.NetBSD,
.Haiku,
.WASI,
.JS,
.Orca,
.Freestanding,
}
/*
// Defined internally by the compiler
Odin_Platform_Subtarget_Type :: enum int {
Default,
iOS,
iPhone,
iPhoneSimulator
Android,
}
*/
Odin_Platform_Subtarget_Type :: type_of(ODIN_PLATFORM_SUBTARGET)
Odin_Platform_Subtarget_Types :: bit_set[Odin_Platform_Subtarget_Type]
@(builtin)
ODIN_PLATFORM_SUBTARGET_IOS :: ODIN_PLATFORM_SUBTARGET == .iPhone || ODIN_PLATFORM_SUBTARGET == .iPhoneSimulator
/*
// Defined internally by the compiler
Odin_Sanitizer_Flag :: enum u32 {
@@ -554,12 +592,25 @@ Odin_Platform_Subtarget_Type :: type_of(ODIN_PLATFORM_SUBTARGET)
Memory = 1,
Thread = 2,
}
Odin_Sanitizer_Flags :: distinct bitset[Odin_Sanitizer_Flag; u32]
Odin_Sanitizer_Flags :: distinct bit_set[Odin_Sanitizer_Flag; u32]
ODIN_SANITIZER_FLAGS // is a constant
*/
Odin_Sanitizer_Flags :: type_of(ODIN_SANITIZER_FLAGS)
/*
// Defined internally by the compiler
Odin_Optimization_Mode :: enum int {
None = -1,
Minimal = 0,
Size = 1,
Speed = 2,
Aggressive = 3,
}
ODIN_OPTIMIZATION_MODE // is a constant
*/
Odin_Optimization_Mode :: type_of(ODIN_OPTIMIZATION_MODE)
/////////////////////////////
// Init Startup Procedures //
@@ -585,6 +636,8 @@ _cleanup_runtime_contextless :: proc "contextless" () {
/////////////////////////////
// type_info_base returns the base-type of a `^Type_Info` stripping the `distinct`ness from the first level
@(require_results)
type_info_base :: proc "contextless" (info: ^Type_Info) -> ^Type_Info {
if info == nil {
return nil
@@ -601,6 +654,10 @@ type_info_base :: proc "contextless" (info: ^Type_Info) -> ^Type_Info {
}
// type_info_core returns the core-type of a `^Type_Info` stripping the `distinct`ness from the first level AND/OR
// returns the backing integer type of an enum or bit_set `^Type_Info`.
// This is also aliased as `type_info_base_without_enum`
@(require_results)
type_info_core :: proc "contextless" (info: ^Type_Info) -> ^Type_Info {
if info == nil {
return nil
@@ -617,28 +674,43 @@ type_info_core :: proc "contextless" (info: ^Type_Info) -> ^Type_Info {
}
return base
}
// type_info_base_without_enum returns the core-type of a `^Type_Info` stripping the `distinct`ness from the first level AND/OR
// returns the backing integer type of an enum or bit_set `^Type_Info`.
// This is also aliased as `type_info_core`
type_info_base_without_enum :: type_info_core
__type_info_of :: proc "contextless" (id: typeid) -> ^Type_Info #no_bounds_check {
MASK :: 1<<(8*size_of(typeid) - 8) - 1
data := transmute(uintptr)id
n := int(data & MASK)
if n < 0 || n >= len(type_table) {
n = 0
n := u64(len(type_table))
i := transmute(u64)id % n
for _ in 0..<n {
ptr := type_table[i]
if ptr != nil && ptr.id == id {
return ptr
}
i = i+1 if i+1 < n else 0
}
return type_table[n]
return type_table[0]
}
when !ODIN_NO_RTTI {
// typeid_base returns the base-type of a `typeid` stripping the `distinct`ness from the first level
typeid_base :: proc "contextless" (id: typeid) -> typeid {
ti := type_info_of(id)
ti = type_info_base(ti)
return ti.id
}
// typeid_core returns the core-type of a `typeid` stripping the `distinct`ness from the first level AND/OR
// returns the backing integer type of an enum or bit_set `typeid`.
// This is also aliased as `typeid_base_without_enum`
typeid_core :: proc "contextless" (id: typeid) -> typeid {
ti := type_info_core(type_info_of(id))
return ti.id
}
// typeid_base_without_enum returns the core-type of a `typeid` stripping the `distinct`ness from the first level AND/OR
// returns the backing integer type of an enum or bit_set `typeid`.
// This is also aliased as `typeid_core`
typeid_base_without_enum :: typeid_core
}
@@ -654,11 +726,15 @@ default_logger_proc :: proc(data: rawptr, level: Logger_Level, text: string, opt
// Nothing
}
// Returns the default logger used by `context.logger`
@(require_results)
default_logger :: proc() -> Logger {
return Logger{default_logger_proc, nil, Logger_Level.Debug, nil}
}
// Returns the default `context`
@(require_results)
default_context :: proc "contextless" () -> Context {
c: Context
__init_context(&c)
@@ -695,13 +771,20 @@ __init_context :: proc "contextless" (c: ^Context) {
c.logger.procedure = default_logger_proc
c.logger.data = nil
c.random_generator.procedure = default_random_generator_proc
c.random_generator.data = nil
}
default_assertion_failure_proc :: proc(prefix, message: string, loc: Source_Code_Location) -> ! {
default_assertion_contextless_failure_proc(prefix, message, loc)
}
default_assertion_contextless_failure_proc :: proc "contextless" (prefix, message: string, loc: Source_Code_Location) -> ! {
when ODIN_OS == .Freestanding {
// Do nothing
} else {
when !ODIN_DISABLE_ASSERT {
when ODIN_OS != .Orca && !ODIN_DISABLE_ASSERT {
print_caller_location(loc)
print_string(" ")
}
@@ -710,7 +793,18 @@ default_assertion_failure_proc :: proc(prefix, message: string, loc: Source_Code
print_string(": ")
print_string(message)
}
print_byte('\n')
when ODIN_OS == .Orca {
assert_fail(
cstring(raw_data(loc.file_path)),
cstring(raw_data(loc.procedure)),
loc.line,
"",
cstring(raw_data(orca_stderr_buffer[:orca_stderr_buffer_idx])),
)
} else {
print_byte('\n')
}
}
trap()
}
File diff suppressed because it is too large Load Diff
+288 -69
View File
@@ -55,7 +55,7 @@ raw_soa_footer_slice :: proc(array: ^$T/#soa[]$E) -> (footer: ^Raw_SOA_Footer_Sl
if array == nil {
return nil
}
field_count := uintptr(intrinsics.type_struct_field_count(E))
field_count := uintptr(len(E) when intrinsics.type_is_array(E) else intrinsics.type_struct_field_count(E))
footer = (^Raw_SOA_Footer_Slice)(uintptr(array) + field_count*size_of(rawptr))
return
}
@@ -64,12 +64,7 @@ raw_soa_footer_dynamic_array :: proc(array: ^$T/#soa[dynamic]$E) -> (footer: ^Ra
if array == nil {
return nil
}
field_count: uintptr
when intrinsics.type_is_array(E) {
field_count = len(E)
} else {
field_count = uintptr(intrinsics.type_struct_field_count(E))
}
field_count := uintptr(len(E) when intrinsics.type_is_array(E) else intrinsics.type_struct_field_count(E))
footer = (^Raw_SOA_Footer_Dynamic_Array)(uintptr(array) + field_count*size_of(rawptr))
return
}
@@ -81,7 +76,7 @@ raw_soa_footer :: proc{
@(builtin, require_results)
make_soa_aligned :: proc($T: typeid/#soa[]$E, length: int, alignment: int, allocator := context.allocator, loc := #caller_location) -> (array: T, err: Allocator_Error) #optional_allocator_error {
make_soa_aligned :: proc($T: typeid/#soa[]$E, #any_int length, alignment: int, allocator := context.allocator, loc := #caller_location) -> (array: T, err: Allocator_Error) #optional_allocator_error {
if length <= 0 {
return
}
@@ -98,7 +93,7 @@ make_soa_aligned :: proc($T: typeid/#soa[]$E, length: int, alignment: int, alloc
ti = type_info_base(ti)
si := &ti.variant.(Type_Info_Struct)
field_count := uintptr(intrinsics.type_struct_field_count(E))
field_count := uintptr(len(E) when intrinsics.type_is_array(E) else intrinsics.type_struct_field_count(E))
total_size := 0
for i in 0..<field_count {
@@ -107,10 +102,11 @@ make_soa_aligned :: proc($T: typeid/#soa[]$E, length: int, alignment: int, alloc
total_size = align_forward_int(total_size, max_align)
}
allocator := allocator
if allocator.procedure == nil {
allocator = context.allocator
}
// Note(Ed) - Sectr Fork: Not a fan. (I want it to assert)
// allocator := allocator
// if allocator.procedure == nil {
// allocator = context.allocator
// }
assert(allocator.procedure != nil)
new_bytes: []byte
@@ -140,20 +136,22 @@ make_soa_aligned :: proc($T: typeid/#soa[]$E, length: int, alignment: int, alloc
}
@(builtin, require_results)
make_soa_slice :: proc($T: typeid/#soa[]$E, length: int, allocator := context.allocator, loc := #caller_location) -> (array: T, err: Allocator_Error) #optional_allocator_error {
make_soa_slice :: proc($T: typeid/#soa[]$E, #any_int length: int, allocator := context.allocator, loc := #caller_location) -> (array: T, err: Allocator_Error) #optional_allocator_error {
return make_soa_aligned(T, length, align_of(E), allocator, loc)
}
@(builtin, require_results)
make_soa_dynamic_array :: proc($T: typeid/#soa[dynamic]$E, allocator := context.allocator, loc := #caller_location) -> (array: T, err: Allocator_Error) #optional_allocator_error {
context.allocator = allocator
reserve_soa(&array, DEFAULT_RESERVE_CAPACITY, loc) or_return
array.allocator = allocator
reserve_soa(&array, 0, loc) or_return
return array, nil
}
@(builtin, require_results)
make_soa_dynamic_array_len :: proc($T: typeid/#soa[dynamic]$E, #any_int length: int, allocator := context.allocator, loc := #caller_location) -> (array: T, err: Allocator_Error) #optional_allocator_error {
context.allocator = allocator
array.allocator = allocator
resize_soa(&array, length, loc) or_return
return array, nil
}
@@ -161,6 +159,7 @@ make_soa_dynamic_array_len :: proc($T: typeid/#soa[dynamic]$E, #any_int length:
@(builtin, require_results)
make_soa_dynamic_array_len_cap :: proc($T: typeid/#soa[dynamic]$E, #any_int length, capacity: int, allocator := context.allocator, loc := #caller_location) -> (array: T, err: Allocator_Error) #optional_allocator_error {
context.allocator = allocator
array.allocator = allocator
reserve_soa(&array, capacity, loc) or_return
resize_soa(&array, length, loc) or_return
return array, nil
@@ -177,18 +176,61 @@ make_soa :: proc{
@builtin
resize_soa :: proc(array: ^$T/#soa[dynamic]$E, length: int, loc := #caller_location) -> Allocator_Error {
resize_soa :: proc(array: ^$T/#soa[dynamic]$E, #any_int length: int, loc := #caller_location) -> Allocator_Error {
if array == nil {
return nil
}
reserve_soa(array, length, loc) or_return
footer := raw_soa_footer(array)
if length > footer.cap {
reserve_soa(array, length, loc) or_return
} else if size_of(E) > 0 && length > footer.len {
ti := type_info_base(type_info_of(typeid_of(T)))
si := &ti.variant.(Type_Info_Struct)
field_count := len(E) when intrinsics.type_is_array(E) else intrinsics.type_struct_field_count(E)
data := (^rawptr)(array)^
soa_offset := 0
for i in 0..<field_count {
type := si.types[i].variant.(Type_Info_Multi_Pointer).elem
soa_offset = align_forward_int(soa_offset, align_of(E))
mem_zero(rawptr(uintptr(data) + uintptr(soa_offset) + uintptr(type.size * footer.len)), type.size * (length - footer.len))
soa_offset += type.size * footer.cap
}
}
footer.len = length
return nil
}
@builtin
non_zero_resize_soa :: proc(array: ^$T/#soa[dynamic]$E, #any_int length: int, loc := #caller_location) -> Allocator_Error {
if array == nil {
return nil
}
non_zero_reserve_soa(array, length, loc) or_return
footer := raw_soa_footer(array)
footer.len = length
return nil
}
@builtin
reserve_soa :: proc(array: ^$T/#soa[dynamic]$E, capacity: int, loc := #caller_location) -> Allocator_Error {
reserve_soa :: proc(array: ^$T/#soa[dynamic]$E, #any_int capacity: int, loc := #caller_location) -> Allocator_Error {
return _reserve_soa(array, capacity, true, loc)
}
@builtin
non_zero_reserve_soa :: proc(array: ^$T/#soa[dynamic]$E, #any_int capacity: int, loc := #caller_location) -> Allocator_Error {
return _reserve_soa(array, capacity, false, loc)
}
_reserve_soa :: proc(array: ^$T/#soa[dynamic]$E, capacity: int, zero_memory: bool, loc := #caller_location) -> Allocator_Error {
if array == nil {
return nil
}
@@ -198,9 +240,10 @@ reserve_soa :: proc(array: ^$T/#soa[dynamic]$E, capacity: int, loc := #caller_lo
return nil
}
if array.allocator.procedure == nil {
array.allocator = context.allocator
}
// Note(Ed) - Sectr Fork: Not a fan. (I want it to assert)
// if array.allocator.procedure == nil {
// array.allocator = context.allocator
// }
assert(array.allocator.procedure != nil)
footer := raw_soa_footer(array)
@@ -213,12 +256,7 @@ reserve_soa :: proc(array: ^$T/#soa[dynamic]$E, capacity: int, loc := #caller_lo
ti = type_info_base(ti)
si := &ti.variant.(Type_Info_Struct)
field_count: uintptr
when intrinsics.type_is_array(E) {
field_count = len(E)
} else {
field_count = uintptr(intrinsics.type_struct_field_count(E))
}
field_count := uintptr(len(E) when intrinsics.type_is_array(E) else intrinsics.type_struct_field_count(E))
assert(footer.cap == old_cap)
old_size := 0
@@ -237,17 +275,77 @@ reserve_soa :: proc(array: ^$T/#soa[dynamic]$E, capacity: int, loc := #caller_lo
old_data := (^rawptr)(array)^
resize: if old_data != nil {
new_bytes, resize_err := array.allocator.procedure(
array.allocator.data, .Resize_Non_Zeroed, new_size, max_align,
old_data, old_size, loc,
)
new_data := raw_data(new_bytes)
#partial switch resize_err {
case .Mode_Not_Implemented: break resize
case .None: // continue resizing
case: return resize_err
}
footer.cap = capacity
old_offset := 0
new_offset := 0
// Correct data memory
// from: |x x y y z z _ _ _|
// to: |x x _ y y _ z z _|
// move old data to the end of the new allocation to avoid overlap
old_data = rawptr(uintptr(new_data) + uintptr(new_size - old_size))
mem_copy(old_data, new_data, old_size)
// now: |_ _ _ x x y y z z|
for i in 0..<field_count {
type := si.types[i].variant.(Type_Info_Multi_Pointer).elem
old_offset = align_forward_int(old_offset, max_align)
new_offset = align_forward_int(new_offset, max_align)
new_data_elem := rawptr(uintptr(new_data) + uintptr(new_offset))
old_data_elem := rawptr(uintptr(old_data) + uintptr(old_offset))
old_size_elem := type.size * old_cap
new_size_elem := type.size * capacity
mem_copy(new_data_elem, old_data_elem, old_size_elem)
(^rawptr)(uintptr(array) + i*size_of(rawptr))^ = new_data_elem
if zero_memory {
mem_zero(rawptr(uintptr(new_data_elem) + uintptr(old_size_elem)), new_size_elem - old_size_elem)
}
old_offset += old_size_elem
new_offset += new_size_elem
}
return nil
}
new_bytes := array.allocator.procedure(
array.allocator.data, .Alloc, new_size, max_align,
array.allocator.data, .Alloc if zero_memory else .Alloc_Non_Zeroed, new_size, max_align,
nil, old_size, loc,
) or_return
new_data := raw_data(new_bytes)
footer.cap = capacity
old_offset := 0
new_offset := 0
// Correct data memory
// from: |x x y y z z| ... |_ _ _ _ _ _ _ _ _|
// to: |x x _ y y _ z z _|
for i in 0..<field_count {
type := si.types[i].variant.(Type_Info_Multi_Pointer).elem
@@ -265,23 +363,36 @@ reserve_soa :: proc(array: ^$T/#soa[dynamic]$E, capacity: int, loc := #caller_lo
new_offset += type.size * capacity
}
array.allocator.procedure(
array.allocator.data, .Free, 0, max_align,
old_data, old_size, loc,
) or_return
if old_data != nil {
array.allocator.procedure(
array.allocator.data, .Free, 0, max_align,
old_data, old_size, loc,
) or_return
}
return nil
}
@builtin
append_soa_elem :: proc(array: ^$T/#soa[dynamic]$E, arg: E, loc := #caller_location) -> (n: int, err: Allocator_Error) #optional_allocator_error {
append_soa_elem :: proc(array: ^$T/#soa[dynamic]$E, #no_broadcast arg: E, loc := #caller_location) -> (n: int, err: Allocator_Error) #optional_allocator_error {
return _append_soa_elem(array, true, arg, loc)
}
@builtin
non_zero_append_soa_elem :: proc(array: ^$T/#soa[dynamic]$E, #no_broadcast arg: E, loc := #caller_location) -> (n: int, err: Allocator_Error) #optional_allocator_error {
return _append_soa_elem(array, false, arg, loc)
}
_append_soa_elem :: proc(array: ^$T/#soa[dynamic]$E, zero_memory: bool, #no_broadcast arg: E, loc := #caller_location) -> (n: int, err: Allocator_Error) #optional_allocator_error {
if array == nil {
return 0, nil
}
if cap(array) <= len(array) + 1 {
cap := 2 * cap(array) + 8
err = reserve_soa(array, cap, loc) // do not 'or_return' here as it could be a partial success
// Same behavior as append_soa_elems but there's only one arg, so we always just add DEFAULT_DYNAMIC_ARRAY_CAPACITY.
cap := 2 * cap(array) + DEFAULT_DYNAMIC_ARRAY_CAPACITY
err = _reserve_soa(array, cap, zero_memory, loc) // do not 'or_return' here as it could be a partial success
}
footer := raw_soa_footer(array)
@@ -290,12 +401,7 @@ append_soa_elem :: proc(array: ^$T/#soa[dynamic]$E, arg: E, loc := #caller_locat
ti := type_info_of(T)
ti = type_info_base(ti)
si := &ti.variant.(Type_Info_Struct)
field_count: uintptr
when intrinsics.type_is_array(E) {
field_count = len(E)
} else {
field_count = uintptr(intrinsics.type_struct_field_count(E))
}
field_count := uintptr(len(E) when intrinsics.type_is_array(E) else intrinsics.type_struct_field_count(E))
data := (^rawptr)(array)^
@@ -326,7 +432,17 @@ append_soa_elem :: proc(array: ^$T/#soa[dynamic]$E, arg: E, loc := #caller_locat
}
@builtin
append_soa_elems :: proc(array: ^$T/#soa[dynamic]$E, args: ..E, loc := #caller_location) -> (n: int, err: Allocator_Error) #optional_allocator_error {
append_soa_elems :: proc(array: ^$T/#soa[dynamic]$E, #no_broadcast args: ..E, loc := #caller_location) -> (n: int, err: Allocator_Error) #optional_allocator_error {
return _append_soa_elems(array, true, args=args, loc=loc)
}
@builtin
non_zero_append_soa_elems :: proc(array: ^$T/#soa[dynamic]$E, #no_broadcast args: ..E, loc := #caller_location) -> (n: int, err: Allocator_Error) #optional_allocator_error {
return _append_soa_elems(array, false, args=args, loc=loc)
}
_append_soa_elems :: proc(array: ^$T/#soa[dynamic]$E, zero_memory: bool, #no_broadcast args: []E, loc := #caller_location) -> (n: int, err: Allocator_Error) #optional_allocator_error {
if array == nil {
return
}
@@ -337,8 +453,8 @@ append_soa_elems :: proc(array: ^$T/#soa[dynamic]$E, args: ..E, loc := #caller_l
}
if cap(array) <= len(array)+arg_len {
cap := 2 * cap(array) + max(8, arg_len)
err = reserve_soa(array, cap, loc) // do not 'or_return' here as it could be a partial success
cap := 2 * cap(array) + max(DEFAULT_DYNAMIC_ARRAY_CAPACITY, arg_len)
err = _reserve_soa(array, cap, zero_memory, loc) // do not 'or_return' here as it could be a partial success
}
arg_len = min(cap(array)-len(array), arg_len)
@@ -347,7 +463,7 @@ append_soa_elems :: proc(array: ^$T/#soa[dynamic]$E, args: ..E, loc := #caller_l
ti := type_info_of(typeid_of(T))
ti = type_info_base(ti)
si := &ti.variant.(Type_Info_Struct)
field_count := uintptr(intrinsics.type_struct_field_count(E))
field_count := uintptr(len(E) when intrinsics.type_is_array(E) else intrinsics.type_struct_field_count(E))
data := (^rawptr)(array)^
@@ -388,8 +504,124 @@ append_soa :: proc{
}
// `append_nothing_soa` appends an empty value to a dynamic SOA array. It returns `1, nil` if successful, and `0, err` when it was not possible,
// whatever `err` happens to be.
@builtin
append_nothing_soa :: proc(array: ^$T/#soa[dynamic]$E, loc := #caller_location) -> (n: int, err: Allocator_Error) #optional_allocator_error {
if array == nil {
return 0, nil
}
prev_len := len(array)
resize_soa(array, len(array)+1, loc) or_return
return len(array)-prev_len, nil
}
// `inject_at_elem_soa` injects an element in a dynamic SOA array at a specified index and moves the previous elements after that index "across"
@builtin
inject_at_elem_soa :: proc(array: ^$T/#soa[dynamic]$E, #any_int index: int, #no_broadcast arg: E, loc := #caller_location) -> (ok: bool, err: Allocator_Error) #no_bounds_check #optional_allocator_error {
when !ODIN_NO_BOUNDS_CHECK {
ensure(index >= 0, "Index must be positive.", loc)
}
if array == nil {
return
}
n := max(len(array), index)
m :: 1
new_len := n + m
resize_soa(array, new_len, loc) or_return
when size_of(E) != 0 {
ti := type_info_base(type_info_of(typeid_of(T)))
si := &ti.variant.(Type_Info_Struct)
field_count := len(E) when intrinsics.type_is_array(E) else intrinsics.type_struct_field_count(E)
item_offset := 0
arg_copy := arg
arg_ptr := &arg_copy
for i in 0..<field_count {
data := (^uintptr)(uintptr(array) + uintptr(si.offsets[i]))^
type := si.types[i].variant.(Type_Info_Multi_Pointer).elem
item_offset = align_forward_int(item_offset, type.align)
src := data + uintptr(index * type.size)
dst := data + uintptr((index + m) * type.size)
mem_copy(rawptr(dst), rawptr(src), (n - index) * type.size)
mem_copy(rawptr(src), rawptr(uintptr(arg_ptr) + uintptr(item_offset)), type.size)
item_offset += type.size
}
}
ok = true
return
}
// `inject_at_elems_soa` injects multiple elements in a dynamic SOA array at a specified index and moves the previous elements after that index "across"
@builtin
inject_at_elems_soa :: proc(array: ^$T/#soa[dynamic]$E, #any_int index: int, #no_broadcast args: ..E, loc := #caller_location) -> (ok: bool, err: Allocator_Error) #no_bounds_check #optional_allocator_error {
when !ODIN_NO_BOUNDS_CHECK {
ensure(index >= 0, "Index must be positive.", loc)
}
if array == nil {
return
}
if len(args) == 0 {
ok = true
return
}
n := max(len(array), index)
m := len(args)
new_len := n + m
resize_soa(array, new_len, loc) or_return
when size_of(E) != 0 {
ti := type_info_base(type_info_of(typeid_of(T)))
si := &ti.variant.(Type_Info_Struct)
field_count := len(E) when intrinsics.type_is_array(E) else intrinsics.type_struct_field_count(E)
item_offset := 0
args_ptr := &args[0]
for i in 0..<field_count {
data := (^uintptr)(uintptr(array) + uintptr(si.offsets[i]))^
type := si.types[i].variant.(Type_Info_Multi_Pointer).elem
item_offset = align_forward_int(item_offset, type.align)
src := data + uintptr(index * type.size)
dst := data + uintptr((index + m) * type.size)
mem_copy(rawptr(dst), rawptr(src), (n - index) * type.size)
for j in 0..<len(args) {
d := rawptr(src + uintptr(j*type.size))
s := rawptr(uintptr(args_ptr) + uintptr(item_offset) + uintptr(j*size_of(E)))
mem_copy(d, s, type.size)
}
item_offset += type.size
}
}
ok = true
return
}
// `inject_at_soa` injects something into a dynamic SOA array at a specified index and moves the previous elements after that index "across"
@builtin inject_at_soa :: proc{inject_at_elem_soa, inject_at_elems_soa}
delete_soa_slice :: proc(array: $T/#soa[]$E, allocator := context.allocator, loc := #caller_location) -> Allocator_Error {
when intrinsics.type_struct_field_count(E) != 0 {
field_count :: len(E) when intrinsics.type_is_array(E) else intrinsics.type_struct_field_count(E)
when field_count != 0 {
array := array
ptr := (^rawptr)(&array)^
free(ptr, allocator, loc) or_return
@@ -398,7 +630,8 @@ delete_soa_slice :: proc(array: $T/#soa[]$E, allocator := context.allocator, loc
}
delete_soa_dynamic_array :: proc(array: $T/#soa[dynamic]$E, loc := #caller_location) -> Allocator_Error {
when intrinsics.type_struct_field_count(E) != 0 {
field_count :: len(E) when intrinsics.type_is_array(E) else intrinsics.type_struct_field_count(E)
when field_count != 0 {
array := array
ptr := (^rawptr)(&array)^
footer := raw_soa_footer(&array)
@@ -416,7 +649,8 @@ delete_soa :: proc{
clear_soa_dynamic_array :: proc(array: ^$T/#soa[dynamic]$E) {
when intrinsics.type_struct_field_count(E) != 0 {
field_count :: len(E) when intrinsics.type_is_array(E) else intrinsics.type_struct_field_count(E)
when field_count != 0 {
footer := raw_soa_footer(array)
footer.len = 0
}
@@ -438,12 +672,7 @@ into_dynamic_soa :: proc(array: $T/#soa[]$E) -> #soa[dynamic]E {
allocator = nil_allocator(),
}
field_count: uintptr
when intrinsics.type_is_array(E) {
field_count = len(E)
} else {
field_count = uintptr(intrinsics.type_struct_field_count(E))
}
field_count := uintptr(len(E) when intrinsics.type_is_array(E) else intrinsics.type_struct_field_count(E))
array := array
dynamic_data := ([^]rawptr)(&d)[:field_count]
@@ -460,19 +689,14 @@ into_dynamic_soa :: proc(array: $T/#soa[]$E) -> #soa[dynamic]E {
// Note: If you the elements to remain in their order, use `ordered_remove_soa`.
// Note: If the index is out of bounds, this procedure will panic.
@builtin
unordered_remove_soa :: proc(array: ^$T/#soa[dynamic]$E, index: int, loc := #caller_location) #no_bounds_check {
unordered_remove_soa :: proc(array: ^$T/#soa[dynamic]$E, #any_int index: int, loc := #caller_location) #no_bounds_check {
bounds_check_error_loc(loc, index, len(array))
if index+1 < len(array) {
ti := type_info_of(typeid_of(T))
ti = type_info_base(ti)
si := &ti.variant.(Type_Info_Struct)
field_count: uintptr
when intrinsics.type_is_array(E) {
field_count = len(E)
} else {
field_count = uintptr(intrinsics.type_struct_field_count(E))
}
field_count := uintptr(len(E) when intrinsics.type_is_array(E) else intrinsics.type_struct_field_count(E))
data := uintptr(array)
for i in 0..<field_count {
@@ -493,19 +717,14 @@ unordered_remove_soa :: proc(array: ^$T/#soa[dynamic]$E, index: int, loc := #cal
// Note: If you the elements do not have to remain in their order, prefer `unordered_remove_soa`.
// Note: If the index is out of bounds, this procedure will panic.
@builtin
ordered_remove_soa :: proc(array: ^$T/#soa[dynamic]$E, index: int, loc := #caller_location) #no_bounds_check {
ordered_remove_soa :: proc(array: ^$T/#soa[dynamic]$E, #any_int index: int, loc := #caller_location) #no_bounds_check {
bounds_check_error_loc(loc, index, len(array))
if index+1 < len(array) {
ti := type_info_of(typeid_of(T))
ti = type_info_base(ti)
si := &ti.variant.(Type_Info_Struct)
field_count: uintptr
when intrinsics.type_is_array(E) {
field_count = len(E)
} else {
field_count = uintptr(intrinsics.type_struct_field_count(E))
}
field_count := uintptr(len(E) when intrinsics.type_is_array(E) else intrinsics.type_struct_field_count(E))
data := uintptr(array)
for i in 0..<field_count {
+1 -1
View File
@@ -6,7 +6,7 @@ when ODIN_DEFAULT_TO_NIL_ALLOCATOR {
} else when ODIN_DEFAULT_TO_PANIC_ALLOCATOR {
default_allocator_proc :: panic_allocator_proc
default_allocator :: panic_allocator
} else when ODIN_ARCH == .wasm32 || ODIN_ARCH == .wasm64p32 {
} else when ODIN_OS != .Orca && (ODIN_ARCH == .wasm32 || ODIN_ARCH == .wasm64p32) {
default_allocator :: default_wasm_allocator
default_allocator_proc :: wasm_allocator_proc
} else {
+16 -3
View File
@@ -1,8 +1,8 @@
package runtime
nil_allocator_proc :: proc(allocator_data: rawptr, mode: Allocator_Mode,
size, alignment: int,
old_memory: rawptr, old_size: int, loc := #caller_location) -> ([]byte, Allocator_Error) {
size, alignment: int,
old_memory: rawptr, old_size: int, loc := #caller_location) -> ([]byte, Allocator_Error) {
switch mode {
case .Alloc, .Alloc_Non_Zeroed:
return nil, .Out_Of_Memory
@@ -23,7 +23,16 @@ nil_allocator_proc :: proc(allocator_data: rawptr, mode: Allocator_Mode,
return nil, .None
}
nil_allocator :: proc() -> Allocator {
// nil_allocator returns an allocator which will return `nil` for any result.
// * `.Alloc`, `.Alloc_Non_Zero`, `.Resize`, `.Resize_Non_Zeroed` will return `nil, .Out_Of_Memory`
// * `.Free` will return `nil, .None`
// * `.Free_All` will return `nil, .Mode_Not_Implemented`
// * `.Query_Features`, `.Query_Info` will return `nil, .Mode_Not_Implemented`
//
// This is extremely useful for creating a dynamic array from a buffer which does not nothing
// on a resize/reserve beyond the originally allocated memory.
@(require_results)
nil_allocator :: proc "contextless" () -> Allocator {
return Allocator{
procedure = nil_allocator_proc,
data = nil,
@@ -72,6 +81,10 @@ panic_allocator_proc :: proc(allocator_data: rawptr, mode: Allocator_Mode,
return nil, nil
}
// panic_allocator returns an allocator which will panic for any non-zero-sized allocation or `query_info`
//
// This is extremely useful for to check when something does a memory operation when it should not, and thus panic.
@(require_results)
panic_allocator :: proc() -> Allocator {
return Allocator{
procedure = panic_allocator_proc,
@@ -1,6 +1,7 @@
package runtime
import "base:intrinsics"
// import "base:sanitizer"
DEFAULT_ARENA_GROWING_MINIMUM_BLOCK_SIZE :: uint(DEFAULT_TEMP_ALLOCATOR_BACKING_SIZE)
@@ -12,7 +13,8 @@ Memory_Block :: struct {
capacity: uint,
}
// NOTE: This is for internal use, prefer `Arena` from `core:mem/virtual` if necessary
// NOTE: This is a growing arena that is only used for the default temp allocator.
// For your own growing arena needs, prefer `Arena` from `core:mem/virtual`.
Arena :: struct {
backing_allocator: Allocator,
curr_block: ^Memory_Block,
@@ -42,15 +44,21 @@ memory_block_alloc :: proc(allocator: Allocator, capacity: uint, alignment: uint
block.base = ([^]byte)(uintptr(block) + base_offset)
block.capacity = uint(end - uintptr(block.base))
// sanitizer.address_poison(block.base, block.capacity)
// Should be zeroed
assert(block.used == 0)
assert(block.prev == nil)
return
}
memory_block_dealloc :: proc(block_to_free: ^Memory_Block, loc := #caller_location) {
memory_block_dealloc :: proc "contextless" (block_to_free: ^Memory_Block, loc := #caller_location) {
if block_to_free != nil {
allocator := block_to_free.allocator
// sanitizer.address_unpoison(block_to_free.base, block_to_free.capacity)
context = default_context()
context.allocator = allocator
mem_free(block_to_free, allocator, loc)
}
}
@@ -82,6 +90,7 @@ alloc_from_memory_block :: proc(block: ^Memory_Block, min_size, alignment: uint)
return
}
data = block.base[block.used+alignment_offset:][:min_size]
// sanitizer.address_unpoison(block.base[block.used:block.used+size])
block.used += size
return
}
@@ -103,32 +112,35 @@ arena_alloc :: proc(arena: ^Arena, size, alignment: uint, loc := #caller_locatio
if size == 0 {
return
}
needed := align_forward_uint(size, alignment)
if arena.curr_block == nil || (safe_add(arena.curr_block.used, needed) or_else 0) > arena.curr_block.capacity {
prev_used := 0 if arena.curr_block == nil else arena.curr_block.used
data, err = alloc_from_memory_block(arena.curr_block, size, alignment)
if err == .Out_Of_Memory {
if arena.minimum_block_size == 0 {
arena.minimum_block_size = DEFAULT_ARENA_GROWING_MINIMUM_BLOCK_SIZE
}
needed := align_forward_uint(size, alignment)
block_size := max(needed, arena.minimum_block_size)
if arena.backing_allocator.procedure == nil {
arena.backing_allocator = default_allocator()
}
// Note(Ed) - Sectr Fork: Not a fan. (I want it to assert)
// if arena.backing_allocator.procedure == nil {
// arena.backing_allocator = default_allocator()
// }
assert(arena.backing_allocator.procedure != nil )
new_block := memory_block_alloc(arena.backing_allocator, block_size, alignment, loc) or_return
new_block.prev = arena.curr_block
arena.curr_block = new_block
arena.total_capacity += new_block.capacity
prev_used = 0
data, err = alloc_from_memory_block(arena.curr_block, size, alignment)
}
prev_used := arena.curr_block.used
data, err = alloc_from_memory_block(arena.curr_block, size, alignment)
arena.total_used += arena.curr_block.used - prev_used
return
}
// `arena_init` will initialize the arena with a usuable block.
// `arena_init` will initialize the arena with a usable block.
// This procedure is not necessary to use the Arena as the default zero as `arena_alloc` will set things up if necessary
@(require_results)
arena_init :: proc(arena: ^Arena, size: uint, backing_allocator: Allocator, loc := #caller_location) -> Allocator_Error {
@@ -160,11 +172,12 @@ arena_free_all :: proc(arena: ^Arena, loc := #caller_location) {
if arena.curr_block != nil {
intrinsics.mem_zero(arena.curr_block.base, arena.curr_block.used)
arena.curr_block.used = 0
// sanitizer.address_poison(arena.curr_block.base, arena.curr_block.capacity)
}
arena.total_used = 0
}
arena_destroy :: proc(arena: ^Arena, loc := #caller_location) {
arena_destroy :: proc "contextless" (arena: ^Arena, loc := #caller_location) {
for arena.curr_block != nil {
free_block := arena.curr_block
arena.curr_block = free_block.prev
@@ -176,6 +189,7 @@ arena_destroy :: proc(arena: ^Arena, loc := #caller_location) {
arena.total_capacity = 0
}
@(require_results)
arena_allocator :: proc(arena: ^Arena) -> Allocator {
return Allocator{arena_allocator_proc, arena}
}
@@ -209,10 +223,25 @@ arena_allocator_proc :: proc(allocator_data: rawptr, mode: Allocator_Mode,
case size == 0:
err = .Mode_Not_Implemented
return
case (uintptr(old_data) & uintptr(alignment-1) == 0) && size < old_size:
// shrink data in-place
data = old_data[:size]
return
case uintptr(old_data) & uintptr(alignment-1) == 0:
if size < old_size {
// shrink data in-place
data = old_data[:size]
return
}
if block := arena.curr_block; block != nil {
start := uint(uintptr(old_memory)) - uint(uintptr(block.base))
old_end := start + old_size
new_end := start + size
if start < old_end && old_end == block.used && new_end <= block.capacity {
// grow data in-place, adjusting next allocation
block.used = uint(new_end)
data = block.base[start:new_end]
// sanitizer.address_unpoison(data)
return
}
}
}
new_memory := arena_alloc(arena, size, alignment, location) or_return
@@ -281,9 +310,11 @@ arena_temp_end :: proc(temp: Arena_Temp, loc := #caller_location) {
if block := arena.curr_block; block != nil {
assert(block.used >= temp.used, "out of order use of arena_temp_end", loc)
amount_to_zero := min(block.used-temp.used, block.capacity-block.used)
amount_to_zero := block.used-temp.used
intrinsics.mem_zero(block.base[temp.used:], amount_to_zero)
// sanitizer.address_poison(block.base[temp.used:block.capacity])
block.used = temp.used
arena.total_used -= amount_to_zero
}
}
+15 -4
View File
@@ -4,11 +4,12 @@ DEFAULT_TEMP_ALLOCATOR_BACKING_SIZE: int : #config(DEFAULT_TEMP_ALLOCATOR_BACKIN
NO_DEFAULT_TEMP_ALLOCATOR: bool : ODIN_OS == .Freestanding || ODIN_DEFAULT_TO_NIL_ALLOCATOR
when NO_DEFAULT_TEMP_ALLOCATOR {
// `Default_Temp_Allocator` is a `nil_allocator` when `NO_DEFAULT_TEMP_ALLOCATOR` is `true`.
Default_Temp_Allocator :: struct {}
default_temp_allocator_init :: proc(s: ^Default_Temp_Allocator, size: int, backing_allocator := context.allocator) {}
default_temp_allocator_destroy :: proc(s: ^Default_Temp_Allocator) {}
default_temp_allocator_destroy :: proc "contextless" (s: ^Default_Temp_Allocator) {}
default_temp_allocator_proc :: nil_allocator_proc
@@ -20,6 +21,11 @@ when NO_DEFAULT_TEMP_ALLOCATOR {
default_temp_allocator_temp_end :: proc(temp: Arena_Temp, loc := #caller_location) {
}
} else {
// `Default_Temp_Allocator` is an `Arena` based type of allocator. See `runtime.Arena` for its implementation.
// The default `context.temp_allocator` is typically called with `free_all(context.temp_allocator)` once per "frame-loop"
// to prevent it from "leaking" memory.
//
// Note: `Default_Temp_Allocator` is a `nil_allocator` when `NO_DEFAULT_TEMP_ALLOCATOR` is `true`.
Default_Temp_Allocator :: struct {
arena: Arena,
}
@@ -28,7 +34,7 @@ when NO_DEFAULT_TEMP_ALLOCATOR {
_ = arena_init(&s.arena, uint(size), backing_allocator)
}
default_temp_allocator_destroy :: proc(s: ^Default_Temp_Allocator) {
default_temp_allocator_destroy :: proc "contextless" (s: ^Default_Temp_Allocator) {
if s != nil {
arena_destroy(&s.arena)
s^ = {}
@@ -40,6 +46,11 @@ when NO_DEFAULT_TEMP_ALLOCATOR {
old_memory: rawptr, old_size: int, loc := #caller_location) -> (data: []byte, err: Allocator_Error) {
s := (^Default_Temp_Allocator)(allocator_data)
// Note(Ed) - Sectr Fork: The arena_alloc was originally doing this anyway,
// but I'm moving it to here since I want to have it assert if this is not set there.
if s.arena.backing_allocator.procedure == nil {
s.arena.backing_allocator = default_allocator()
}
return arena_allocator_proc(&s.arena, mode, size, alignment, old_memory, old_size, loc)
}
@@ -56,7 +67,7 @@ when NO_DEFAULT_TEMP_ALLOCATOR {
}
@(fini, private)
_destroy_temp_allocator_fini :: proc() {
_destroy_temp_allocator_fini :: proc "contextless" () {
default_temp_allocator_destroy(&global_default_temp_allocator_data)
}
}
@@ -70,7 +81,7 @@ DEFAULT_TEMP_ALLOCATOR_TEMP_GUARD :: #force_inline proc(ignore := false, loc :=
}
}
@(require_results)
default_temp_allocator :: proc(allocator: ^Default_Temp_Allocator) -> Allocator {
return Allocator{
procedure = default_temp_allocator_proc,
+244
View File
@@ -0,0 +1,244 @@
/*
Declarations which are required by the compiler
## Descriptions of files
There are a lot of files in this package and below is described roughly what
kind of functionality is placed in different files:
| File pattern | Description
|----------------------|------------------------------------------------------|
| `core.odin` | Contains the declarations that compiler will require to be present. Contains context-related declarations, `Type_Info` declarations and some other types used to implement the runtime and other packages. |
| `core_builtin*.odin` | Contain `@(builtin)` declarations that can be used without importing the package. Most of them aren't required by the compiler |
| `default_*.odin` | Contain default implementations for context allocators |
| `entry_*.odin` | Contain OS-specific entry points |
| `os_specific_*.odin` | Contain OS-specific utility procedures |
| `*internal*.odin` | Contain implementations for internal procedures that can be called by the compiler |
## Implementing custom runtime
For embedded and kernel development it might be required to re-implement parts
of the `base:runtime` package. This can include changing the default printing
procedures that handle console output when the program panics, custom
entry-points, tailored for a specific platform or execution environment, or
simply switching up implementations of some procedures.
In case this is required, the following is suggested:
1. Define `$ODIN_ROOT` environment variable to point to a directory within your
project that contains the following directories: `base/`, `core/` and `vendor/`.
2. Inside the `$ODIN_ROOT/base` subdirectory, implement the *necessary
declarations*.
What constitutes the necessary definitions is described below.
### Context-related
The compiler will require these declarations as they concern the `context`
variable.
* `Maybe`
* `Source_Code_Location`
* `Context`
* `Allocator`
* `Random_Generator`
* `Logger`
* `__init_context`
### Runtime initialization/cleanup
These are not strictly required for compilation, but if global variables or
`@(init)`/`@(fini)` blocks are used, these procedures need to be called inside
the entry point.
* `_startup_runtime`
* `_cleanup_runtime`
### Type assertion check
These procedures are called every time `.(Type)` expressions are used in order
to check the union tag or the underlying type of `any` before returning the
value of the underlying type. These are not required if `-no-type-assert` is
specified.
* `type_assertion_check`
* `type_assertion_check2` (takes in typeid)
### Bounds checking procedures
These procedures are called every time index or slicing expression are used in
order to perform bounds-checking before the actual operation. These are not
required if the `-no-bounds-check` option is specified.
* `bounds_check_error`
* `matrix_bounds_check_error`
* `slice_expr_error_hi`
* `slice_expr_error_lo_hi`
* `multi_pointer_slice_expr_error`
### cstring calls
If `cstring` or `cstring16` types are used, these procedures are required.
* `cstring_to_string`
* `cstring_len`
* `cstring16_to_string16`
* `cstring16_len`
### Comparison
These procedures are required for comparison operators between strings and other
compound types to function properly. If strings, structs nor unions are compared,
only `string_eq` procedure is required.
* `memory_equal`
* `memory_compare`
* `memory_compare_zero`
* `cstring_eq`
* `cstring16_eq`
* `cstring_ne`
* `cstring16_ne`
* `cstring_lt`
* `cstring16_lt`
* `cstring_gt`
* `cstring16_gt`
* `cstring_le`
* `cstring16_le`
* `cstring_ge`
* `cstring16_ge`
* `string_eq`
* `string16_eq`
* `string_ne`
* `string16_ne`
* `string_lt`
* `string16_lt`
* `string_gt`
* `string16_gt`
* `string_le`
* `string16_le`
* `string_ge`
* `string16_ge`
* `complex32_eq`
* `complex32_ne`
* `complex64_eq`
* `complex64_ne`
* `complex128_eq`
* `complex128_ne`
* `quaternion64_eq`
* `quaternion64_ne`
* `quaternion128_eq`
* `quaternion128_ne`
* `quaternion256_eq`
* `quaternion256_ne`
### for-in `string` type
These procedures are required to iterate strings using `for ... in` loop. If this
kind of loop isn't used, these procedures aren't required.
* `string_decode_rune`
* `string_decode_last_rune` (for `#reverse for`)
### Required when RTTI is enabled (the vast majority of targets)
These declarations are required unless the `-no-rtti` compiler option is
specified. Note that in order to be useful, some other procedures need to be
implemented. Those procedures aren't mentioned here as the compiler won't
complain if they're missing.
* `Type_Info`
* `type_table`
* `__type_info_of`
### Hashing
Required if maps are used
* `default_hasher`
* `default_hasher_cstring`
* `default_hasher_string`
### Pseudo-CRT required procedured due to LLVM but useful in general
* `memset`
* `memcpy`
* `memove`
### Procedures required by the LLVM backend if u128/i128 is used
* `umodti3`
* `udivti3`
* `modti3`
* `divti3`
* `fixdfti`
* `fixunsdfti`
* `fixunsdfdi`
* `floattidf`
* `floattidf_unsigned`
* `truncsfhf2`
* `truncdfhf2`
* `gnu_h2f_ieee`
* `gnu_f2h_ieee`
* `extendhfsf2`
### Procedures required by the LLVM backend if f16 is used (WASM only)
* `__ashlti3`
* `__multi3`
### When -no-crt is defined (windows only)
* `_tls_index`
* `_fltused`
### Arithmetic
* `quo_complex32`
* `quo_complex64`
* `quo_complex128`
* `mul_quaternion64`
* `mul_quaternion128`
* `mul_quaternion256`
* `quo_quaternion64`
* `quo_quaternion128`
* `quo_quaternion256`
* `abs_complex32`
* `abs_complex64`
* `abs_complex128`
* `abs_quaternion64`
* `abs_quaternion128`
* `abs_quaternion256`
## Map specific calls
* `map_seed_from_map_data`
* `__dynamic_map_check_grow` (for static map calls)
* `map_insert_hash_dynamic` (for static map calls)
* `__dynamic_map_get` (for dynamic map calls)
* `__dynamic_map_set` (for dynamic map calls)
## Dynamic literals (`[dynamic]T` and `map[K]V`) (can be disabled with `-no-dynamic-literals`)
* `__dynamic_array_reserve`
* `__dynamic_array_append`
* `__dynamic_map_reserve`
### Objective-C specific
* `objc_lookUpClass`
* `sel_registerName`
* `objc_allocateClassPair`
### Other required declarations
This is required without conditions.
* `Load_Directory_File`
*/
package runtime
-180
View File
@@ -1,180 +0,0 @@
package runtime
/*
package runtime has numerous entities (declarations) which are required by the compiler to function.
## Basic types and calls (and anything they rely on)
Source_Code_Location
Context
Allocator
Logger
__init_context
_cleanup_runtime
## cstring calls
cstring_to_string
cstring_len
## Required when RTTI is enabled (the vast majority of targets)
Type_Info
type_table
__type_info_of
## Hashing
default_hasher
default_hasher_cstring
default_hasher_string
## Pseudo-CRT required procedured due to LLVM but useful in general
memset
memcpy
memove
## Procedures required by the LLVM backend if u128/i128 is used
umodti3
udivti3
modti3
divti3
fixdfti
fixunsdfti
fixunsdfdi
floattidf
floattidf_unsigned
truncsfhf2
truncdfhf2
gnu_h2f_ieee
gnu_f2h_ieee
extendhfsf2
## Procedures required by the LLVM backend if f16 is used
__ashlti3 // wasm specific
__multi3 // wasm specific
## Required an entry point is defined (i.e. 'main')
args__
## When -no-crt is defined (and not a wasm target) (mostly due to LLVM)
_tls_index
_fltused
## Bounds checking procedures (when not disabled with -no-bounds-check)
bounds_check_error
matrix_bounds_check_error
slice_expr_error_hi
slice_expr_error_lo_hi
multi_pointer_slice_expr_error
## Type assertion check
type_assertion_check
type_assertion_check2 // takes in typeid
## Arithmetic
quo_complex32
quo_complex64
quo_complex128
mul_quaternion64
mul_quaternion128
mul_quaternion256
quo_quaternion64
quo_quaternion128
quo_quaternion256
abs_complex32
abs_complex64
abs_complex128
abs_quaternion64
abs_quaternion128
abs_quaternion256
## Comparison
memory_equal
memory_compare
memory_compare_zero
cstring_eq
cstring_ne
cstring_lt
cstring_gt
cstring_le
cstring_gt
string_eq
string_ne
string_lt
string_gt
string_le
string_gt
complex32_eq
complex32_ne
complex64_eq
complex64_ne
complex128_eq
complex128_ne
quaternion64_eq
quaternion64_ne
quaternion128_eq
quaternion128_ne
quaternion256_eq
quaternion256_ne
## Map specific calls
map_seed_from_map_data
__dynamic_map_check_grow // static map calls
map_insert_hash_dynamic // static map calls
__dynamic_map_get // dynamic map calls
__dynamic_map_set // dynamic map calls
## Dynamic literals ([dymamic]T and map[K]V) (can be disabled with -no-dynamic-literals)
__dynamic_array_reserve
__dynamic_array_append
__dynamic_map_reserve
## Objective-C specific
objc_lookUpClass
sel_registerName
objc_allocateClassPair
## for-in `string` type
string_decode_rune
string_decode_last_rune // #reverse for
*/
+10 -6
View File
@@ -16,9 +16,11 @@ __dynamic_array_reserve :: proc(array_: rawptr, elem_size, elem_align: int, cap:
// NOTE(tetra, 2020-01-26): We set the allocator before earlying-out below, because user code is usually written
// assuming that appending/reserving will set the allocator, if it is not already set.
if array.allocator.procedure == nil {
array.allocator = context.allocator
}
// Note(Ed) - Sectr Fork: Not a fan. (I want it to assert)
// if array.allocator.procedure == nil {
// array.allocator = context.allocator
// }
assert(array.allocator.procedure != nil)
if cap <= array.cap {
@@ -50,9 +52,11 @@ __dynamic_array_shrink :: proc(array_: rawptr, elem_size, elem_align: int, new_c
// NOTE(tetra, 2020-01-26): We set the allocator before earlying-out below, because user code is usually written
// assuming that appending/reserving will set the allocator, if it is not already set.
if array.allocator.procedure == nil {
array.allocator = context.allocator
}
// Note(Ed) - Sectr Fork: Not a fan. (I want it to assert)
// if array.allocator.procedure == nil {
// array.allocator = context.allocator
// }
assert(array.allocator.procedure != nil)
if new_cap > array.cap {
+106 -32
View File
@@ -6,8 +6,6 @@ _ :: intrinsics
// High performance, cache-friendly, open-addressed Robin Hood hashing hash map
// data structure with various optimizations for Odin.
//
// Copyright 2022 (c) Dale Weiler
//
// The core of the hash map data structure is the Raw_Map struct which is a
// type-erased representation of the map. This type-erased representation is
// used in two ways: static and dynamic. When static type information is known,
@@ -158,21 +156,21 @@ map_cell_index_static :: #force_inline proc "contextless" (cells: [^]Map_Cell($T
} else when (N & (N - 1)) == 0 && N <= 8*size_of(uintptr) {
// Likely case, N is a power of two because T is a power of two.
// Unique case, no need to index data here since only one element.
when N == 1 {
return &cells[index].data[0]
}
// Compute the integer log 2 of N, this is the shift amount to index the
// correct cell. Odin's intrinsics.count_leading_zeros does not produce a
// constant, hence this approach. We only need to check up to N = 64.
SHIFT :: 1 when N < 2 else
2 when N < 4 else
3 when N < 8 else
4 when N < 16 else
5 when N < 32 else 6
SHIFT :: 1 when N == 2 else
2 when N == 4 else
3 when N == 8 else
4 when N == 16 else
5 when N == 32 else 6
#assert(SHIFT <= MAP_CACHE_LINE_LOG2)
// Unique case, no need to index data here since only one element.
when N == 1 {
return &cells[index >> SHIFT].data[0]
} else {
return &cells[index >> SHIFT].data[index & (N - 1)]
}
return &cells[index >> SHIFT].data[index & (N - 1)]
} else {
// Least likely (and worst case), we pay for a division operation but we
// assume the compiler does not actually generate a division. N will be in the
@@ -400,7 +398,7 @@ map_alloc_dynamic :: proc "odin" (info: ^Map_Info, log2_capacity: uintptr, alloc
// This procedure returns the address of the just inserted value, and will
// return 'nil' if there was no room to insert the entry
@(require_results)
map_insert_hash_dynamic :: proc "odin" (#no_alias m: ^Raw_Map, #no_alias info: ^Map_Info, h: Map_Hash, ik: uintptr, iv: uintptr) -> (result: uintptr) {
map_insert_hash_dynamic_with_key :: proc "odin" (#no_alias m: ^Raw_Map, #no_alias info: ^Map_Info, h: Map_Hash, ik: uintptr, iv: uintptr) -> (key: uintptr, result: uintptr) {
h := h
pos := map_desired_position(m^, h)
distance := uintptr(0)
@@ -436,7 +434,11 @@ map_insert_hash_dynamic :: proc "odin" (#no_alias m: ^Raw_Map, #no_alias info: ^
intrinsics.mem_copy_non_overlapping(rawptr(v_dst), rawptr(v), size_of_v)
hs[pos] = h
return result if result != 0 else v_dst
if result == 0 {
key = k_dst
result = v_dst
}
return
}
if map_hash_is_deleted(element_hash) {
@@ -444,13 +446,14 @@ map_insert_hash_dynamic :: proc "odin" (#no_alias m: ^Raw_Map, #no_alias info: ^
}
if probe_distance := map_probe_distance(m^, element_hash, pos); distance > probe_distance {
if result == 0 {
result = map_cell_index_dynamic(vs, info.vs, pos)
}
kp := map_cell_index_dynamic(ks, info.ks, pos)
vp := map_cell_index_dynamic(vs, info.vs, pos)
if result == 0 {
key = kp
result = vp
}
intrinsics.mem_copy_non_overlapping(rawptr(tk), rawptr(k), size_of_k)
intrinsics.mem_copy_non_overlapping(rawptr(k), rawptr(kp), size_of_k)
intrinsics.mem_copy_non_overlapping(rawptr(kp), rawptr(tk), size_of_k)
@@ -491,7 +494,11 @@ map_insert_hash_dynamic :: proc "odin" (#no_alias m: ^Raw_Map, #no_alias info: ^
intrinsics.mem_copy_non_overlapping(rawptr(v_dst), rawptr(v), size_of_v)
hs[pos] = h
return result if result != 0 else v_dst
if result == 0 {
key = k_dst
result = v_dst
}
return
}
k_src := map_cell_index_dynamic(ks, info.ks, la_pos)
@@ -501,6 +508,7 @@ map_insert_hash_dynamic :: proc "odin" (#no_alias m: ^Raw_Map, #no_alias info: ^
if probe_distance < look_ahead {
// probed can be made ideal while placing saved (ending condition)
if result == 0 {
key = k_dst
result = v_dst
}
intrinsics.mem_copy_non_overlapping(rawptr(k_dst), rawptr(k), size_of_k)
@@ -550,6 +558,7 @@ map_insert_hash_dynamic :: proc "odin" (#no_alias m: ^Raw_Map, #no_alias info: ^
} else {
// place saved, save probed
if result == 0 {
key = k_dst
result = v_dst
}
intrinsics.mem_copy_non_overlapping(rawptr(k_dst), rawptr(k), size_of_k)
@@ -568,6 +577,12 @@ map_insert_hash_dynamic :: proc "odin" (#no_alias m: ^Raw_Map, #no_alias info: ^
}
}
@(require_results)
map_insert_hash_dynamic :: #force_inline proc "odin" (#no_alias m: ^Raw_Map, #no_alias info: ^Map_Info, h: Map_Hash, ik: uintptr, iv: uintptr) -> (result: uintptr) {
_, result = map_insert_hash_dynamic_with_key(m, info, h, ik, iv)
return
}
@(require_results)
map_grow_dynamic :: proc "odin" (#no_alias m: ^Raw_Map, #no_alias info: ^Map_Info, loc := #caller_location) -> Allocator_Error {
log2_capacity := map_log2_cap(m^)
@@ -577,7 +592,7 @@ map_grow_dynamic :: proc "odin" (#no_alias m: ^Raw_Map, #no_alias info: ^Map_Inf
@(require_results)
map_reserve_dynamic :: proc "odin" (#no_alias m: ^Raw_Map, #no_alias info: ^Map_Info, new_capacity: uintptr, loc := #caller_location) -> Allocator_Error {
map_reserve_dynamic :: #force_no_inline proc "odin" (#no_alias m: ^Raw_Map, #no_alias info: ^Map_Info, new_capacity: uintptr, loc := #caller_location) -> Allocator_Error {
@(require_results)
ceil_log2 :: #force_inline proc "contextless" (x: uintptr) -> uintptr {
z := intrinsics.count_leading_zeros(x)
@@ -587,9 +602,11 @@ map_reserve_dynamic :: proc "odin" (#no_alias m: ^Raw_Map, #no_alias info: ^Map_
return size_of(uintptr)*8 - 1 - z
}
if m.allocator.procedure == nil {
m.allocator = context.allocator
}
// Note(Ed) - Sectr Fork: Not a fan. (I want it to assert)
// if m.allocator.procedure == nil {
// m.allocator = context.allocator
// }
assert( m.allocator.procedure != nil)
new_capacity := new_capacity
old_capacity := uintptr(map_cap(m^))
@@ -641,10 +658,12 @@ map_reserve_dynamic :: proc "odin" (#no_alias m: ^Raw_Map, #no_alias info: ^Map_
@(require_results)
map_shrink_dynamic :: proc "odin" (#no_alias m: ^Raw_Map, #no_alias info: ^Map_Info, loc := #caller_location) -> (did_shrink: bool, err: Allocator_Error) {
if m.allocator.procedure == nil {
m.allocator = context.allocator
}
map_shrink_dynamic :: #force_no_inline proc "odin" (#no_alias m: ^Raw_Map, #no_alias info: ^Map_Info, loc := #caller_location) -> (did_shrink: bool, err: Allocator_Error) {
// Note(Ed) - Sectr Fork: Not a fan. (I want it to assert)
// if m.allocator.procedure == nil {
// m.allocator = context.allocator
// }
assert( m.allocator.procedure != nil)
// Cannot shrink the capacity if the number of items in the map would exceed
// one minus the current log2 capacity's resize threshold. That is the shrunk
@@ -688,7 +707,7 @@ map_shrink_dynamic :: proc "odin" (#no_alias m: ^Raw_Map, #no_alias info: ^Map_I
}
@(require_results)
map_free_dynamic :: proc "odin" (m: Raw_Map, info: ^Map_Info, loc := #caller_location) -> Allocator_Error {
map_free_dynamic :: #force_no_inline proc "odin" (m: Raw_Map, info: ^Map_Info, loc := #caller_location) -> Allocator_Error {
ptr := rawptr(map_data(m))
size := int(map_total_allocation_size(uintptr(map_cap(m)), info))
err := mem_free_with_size(ptr, size, m.allocator, loc)
@@ -700,7 +719,7 @@ map_free_dynamic :: proc "odin" (m: Raw_Map, info: ^Map_Info, loc := #caller_loc
}
@(require_results)
map_lookup_dynamic :: proc "contextless" (m: Raw_Map, #no_alias info: ^Map_Info, k: uintptr) -> (index: uintptr, ok: bool) {
map_lookup_dynamic :: #force_no_inline proc "contextless" (m: Raw_Map, #no_alias info: ^Map_Info, k: uintptr) -> (index: uintptr, ok: bool) {
if map_len(m) == 0 {
return 0, false
}
@@ -723,7 +742,7 @@ map_lookup_dynamic :: proc "contextless" (m: Raw_Map, #no_alias info: ^Map_Info,
}
}
@(require_results)
map_exists_dynamic :: proc "contextless" (m: Raw_Map, #no_alias info: ^Map_Info, k: uintptr) -> (ok: bool) {
map_exists_dynamic :: #force_no_inline proc "contextless" (m: Raw_Map, #no_alias info: ^Map_Info, k: uintptr) -> (ok: bool) {
if map_len(m) == 0 {
return false
}
@@ -749,7 +768,7 @@ map_exists_dynamic :: proc "contextless" (m: Raw_Map, #no_alias info: ^Map_Info,
@(require_results)
map_erase_dynamic :: #force_inline proc "contextless" (#no_alias m: ^Raw_Map, #no_alias info: ^Map_Info, k: uintptr) -> (old_k, old_v: uintptr, ok: bool) {
map_erase_dynamic :: #force_no_inline proc "contextless" (#no_alias m: ^Raw_Map, #no_alias info: ^Map_Info, k: uintptr) -> (old_k, old_v: uintptr, ok: bool) {
index := map_lookup_dynamic(m^, info, k) or_return
ks, vs, hs, _, _ := map_kvh_data_dynamic(m^, info)
hs[index] |= TOMBSTONE_MASK
@@ -941,10 +960,36 @@ __dynamic_map_set_extra :: proc "odin" (#no_alias m: ^Raw_Map, #no_alias info: ^
return nil, rawptr(result)
}
__dynamic_map_entry :: proc "odin" (#no_alias m: ^Raw_Map, #no_alias info: ^Map_Info, key: rawptr, zero: rawptr, loc := #caller_location) -> (key_ptr: rawptr, value_ptr: rawptr, just_inserted: bool, err: Allocator_Error) {
hash := info.key_hasher(key, map_seed(m^))
if key_ptr, value_ptr = __dynamic_map_get_key_and_value(m, info, hash, key); value_ptr != nil {
return
}
has_grown: bool
if err, has_grown = __dynamic_map_check_grow(m, info, loc); err != nil {
return
} else if has_grown {
hash = info.key_hasher(key, map_seed(m^))
}
kp, vp := map_insert_hash_dynamic_with_key(m, info, hash, uintptr(key), uintptr(zero))
key_ptr = rawptr(kp)
value_ptr = rawptr(vp)
m.len += 1
just_inserted = true
return
}
// IMPORTANT: USED WITHIN THE COMPILER
@(private)
__dynamic_map_reserve :: proc "odin" (#no_alias m: ^Raw_Map, #no_alias info: ^Map_Info, new_capacity: uint, loc := #caller_location) -> Allocator_Error {
if m == nil {
return nil
}
return map_reserve_dynamic(m, info, uintptr(new_capacity), loc)
}
@@ -989,3 +1034,32 @@ default_hasher_cstring :: proc "contextless" (data: rawptr, seed: uintptr) -> ui
h &= HASH_MASK
return uintptr(h) | uintptr(uintptr(h) == 0)
}
default_hasher_f64 :: proc "contextless" (f: f64, seed: uintptr) -> uintptr {
f := f
buf: [size_of(f)]u8
if f == 0 {
return default_hasher(&buf, seed, size_of(buf))
}
if f != f {
// TODO(bill): What should the logic be for NaNs?
return default_hasher(&f, seed, size_of(f))
}
return default_hasher(&f, seed, size_of(f))
}
default_hasher_complex128 :: proc "contextless" (x, y: f64, seed: uintptr) -> uintptr {
seed := seed
seed = default_hasher_f64(x, seed)
seed = default_hasher_f64(y, seed)
return seed
}
default_hasher_quaternion256 :: proc "contextless" (x, y, z, w: f64, seed: uintptr) -> uintptr {
seed := seed
seed = default_hasher_f64(x, seed)
seed = default_hasher_f64(y, seed)
seed = default_hasher_f64(z, seed)
seed = default_hasher_f64(w, seed)
return seed
}
+6 -3
View File
@@ -1,6 +1,6 @@
//+private
//+build linux, darwin, freebsd, openbsd, netbsd, haiku
//+no-instrumentation
#+private
#+build linux, darwin, freebsd, openbsd, netbsd, haiku
#+no-instrumentation
package runtime
import "base:intrinsics"
@@ -34,6 +34,9 @@ when ODIN_BUILD_MODE == .Dynamic {
} else when ODIN_OS == .Darwin && ODIN_ARCH == .arm64 {
@require foreign import entry "entry_unix_no_crt_darwin_arm64.asm"
SYS_exit :: 1
} else when ODIN_ARCH == .riscv64 {
@require foreign import entry "entry_unix_no_crt_riscv64.asm"
SYS_exit :: 93
}
@(link_name="_start_odin", linkage="strong", require)
_start_odin :: proc "c" (argc: i32, argv: [^]cstring) -> ! {
+2 -1
View File
@@ -3,6 +3,7 @@ bits 64
extern _start_odin
global _start
section .note.GNU-stack
section .text
;; Entry point for programs that specify -no-crt option
@@ -35,7 +36,7 @@ _start:
xor rbp, rbp
;; Load argc into 1st param reg, argv into 2nd param reg
pop rdi
mov rdx, rsi
mov rsi, rsp
;; Align stack pointer down to 16-bytes (sysv calling convention)
and rsp, -16
;; Call into odin entry point
@@ -0,0 +1,10 @@
.text
.globl _start
_start:
ld a0, 0(sp)
addi a1, sp, 8
addi sp, sp, ~15
call _start_odin
ebreak
+33 -14
View File
@@ -1,20 +1,39 @@
//+private
//+build wasm32, wasm64p32
//+no-instrumentation
#+private
#+build wasm32, wasm64p32
#+no-instrumentation
package runtime
import "base:intrinsics"
when !ODIN_TEST && !ODIN_NO_ENTRY_POINT {
@(link_name="_start", linkage="strong", require, export)
_start :: proc "c" () {
context = default_context()
#force_no_inline _startup_runtime()
intrinsics.__entry_point()
when ODIN_OS == .Orca {
@(linkage="strong", require, export)
oc_on_init :: proc "c" () {
context = default_context()
#force_no_inline _startup_runtime()
intrinsics.__entry_point()
}
@(linkage="strong", require, export)
oc_on_terminate :: proc "c" () {
context = default_context()
#force_no_inline _cleanup_runtime()
}
} else {
@(link_name="_start", linkage="strong", require, export)
_start :: proc "c" () {
context = default_context()
when ODIN_OS == .WASI {
_wasi_setup_args()
}
#force_no_inline _startup_runtime()
intrinsics.__entry_point()
}
@(link_name="_end", linkage="strong", require, export)
_end :: proc "c" () {
context = default_context()
#force_no_inline _cleanup_runtime()
}
}
@(link_name="_end", linkage="strong", require, export)
_end :: proc "c" () {
context = default_context()
#force_no_inline _cleanup_runtime()
}
}
}
+18 -5
View File
@@ -1,6 +1,6 @@
//+private
//+build windows
//+no-instrumentation
#+private
#+build windows
#+no-instrumentation
package runtime
import "base:intrinsics"
@@ -10,8 +10,9 @@ when ODIN_BUILD_MODE == .Dynamic {
DllMain :: proc "system" (hinstDLL: rawptr, fdwReason: u32, lpReserved: rawptr) -> b32 {
context = default_context()
// Populate Windows DLL-specific global
// Populate Windows DLL-specific globals
dll_forward_reason = DLL_Forward_Reason(fdwReason)
dll_instance = hinstDLL
switch dll_forward_reason {
case .Process_Attach:
@@ -27,7 +28,19 @@ when ODIN_BUILD_MODE == .Dynamic {
return true
}
} else when !ODIN_TEST && !ODIN_NO_ENTRY_POINT {
when ODIN_ARCH == .i386 || ODIN_NO_CRT {
when ODIN_ARCH == .i386 && !ODIN_NO_CRT {
// Windows i386 with CRT: libcmt provides mainCRTStartup which calls _main
// Note: "c" calling convention adds underscore prefix automatically on i386
@(link_name="main", linkage="strong", require)
main :: proc "c" (argc: i32, argv: [^]cstring) -> i32 {
args__ = argv[:argc]
context = default_context()
#force_no_inline _startup_runtime()
intrinsics.__entry_point()
#force_no_inline _cleanup_runtime()
return 0
}
} else when ODIN_NO_CRT {
@(link_name="mainCRTStartup", linkage="strong", require)
mainCRTStartup :: proc "system" () -> i32 {
context = default_context()
+4
View File
@@ -4,6 +4,8 @@ package runtime
bounds_trap :: proc "contextless" () -> ! {
when ODIN_OS == .Windows {
windows_trap_array_bounds()
} else when ODIN_OS == .Orca {
abort_ext("", "", 0, "bounds trap")
} else {
trap()
}
@@ -13,6 +15,8 @@ bounds_trap :: proc "contextless" () -> ! {
type_assertion_trap :: proc "contextless" () -> ! {
when ODIN_OS == .Windows {
windows_trap_type_assertion()
} else when ODIN_OS == .Orca {
abort_ext("", "", 0, "type assertion trap")
} else {
trap()
}
+34 -22
View File
@@ -2,6 +2,7 @@ package runtime
import "base:intrinsics"
@(require_results)
heap_allocator :: proc() -> Allocator {
return Allocator{
procedure = heap_allocator_proc,
@@ -19,29 +20,41 @@ heap_allocator_proc :: proc(allocator_data: rawptr, mode: Allocator_Mode,
// the pointer we return to the user.
//
aligned_alloc :: proc(size, alignment: int, old_ptr: rawptr = nil, zero_memory := true) -> ([]byte, Allocator_Error) {
aligned_alloc :: proc(size, alignment: int, old_ptr: rawptr, old_size: int, zero_memory := true) -> ([]byte, Allocator_Error) {
// Not(flysand): We need to reserve enough space for alignment, which
// includes the user data itself, the space to store the pointer to
// allocation start, as well as the padding required to align both
// the user data and the pointer.
a := max(alignment, align_of(rawptr))
space := size + a - 1
space := a-1 + size_of(rawptr) + size
allocated_mem: rawptr
if old_ptr != nil {
force_copy := old_ptr != nil && alignment > align_of(rawptr)
if old_ptr != nil && !force_copy {
original_old_ptr := ([^]rawptr)(old_ptr)[-1]
allocated_mem = heap_resize(original_old_ptr, space+size_of(rawptr))
allocated_mem = heap_resize(original_old_ptr, space)
} else {
allocated_mem = heap_alloc(space+size_of(rawptr), zero_memory)
allocated_mem = heap_alloc(space, zero_memory)
}
aligned_mem := rawptr(([^]u8)(allocated_mem)[size_of(rawptr):])
ptr := uintptr(aligned_mem)
aligned_ptr := (ptr - 1 + uintptr(a)) & -uintptr(a)
diff := int(aligned_ptr - ptr)
if (size + diff) > space || allocated_mem == nil {
aligned_ptr := (ptr + uintptr(a)-1) & ~(uintptr(a)-1)
if allocated_mem == nil {
aligned_free(old_ptr)
aligned_free(allocated_mem)
return nil, .Out_Of_Memory
}
aligned_mem = rawptr(aligned_ptr)
([^]rawptr)(aligned_mem)[-1] = allocated_mem
if force_copy {
mem_copy_non_overlapping(aligned_mem, old_ptr, min(old_size, size))
aligned_free(old_ptr)
}
return byte_slice(aligned_mem, size), nil
}
@@ -53,22 +66,24 @@ heap_allocator_proc :: proc(allocator_data: rawptr, mode: Allocator_Mode,
aligned_resize :: proc(p: rawptr, old_size: int, new_size: int, new_alignment: int, zero_memory := true) -> (new_memory: []byte, err: Allocator_Error) {
if p == nil {
return nil, nil
return aligned_alloc(new_size, new_alignment, nil, old_size, zero_memory)
}
new_memory = aligned_alloc(new_size, new_alignment, p, zero_memory) or_return
new_memory = aligned_alloc(new_size, new_alignment, p, old_size, zero_memory) or_return
// NOTE: heap_resize does not zero the new memory, so we do it
if zero_memory && new_size > old_size {
new_region := raw_data(new_memory[old_size:])
intrinsics.mem_zero(new_region, new_size - old_size)
when ODIN_OS != .Windows {
// NOTE: heap_resize does not zero the new memory, so we do it
if zero_memory && new_size > old_size {
new_region := raw_data(new_memory[old_size:])
conditional_mem_zero(new_region, new_size - old_size)
}
}
return
}
switch mode {
case .Alloc, .Alloc_Non_Zeroed:
return aligned_alloc(size, alignment, nil, mode == .Alloc)
return aligned_alloc(size, alignment, nil, 0, mode == .Alloc)
case .Free:
aligned_free(old_memory)
@@ -77,9 +92,6 @@ heap_allocator_proc :: proc(allocator_data: rawptr, mode: Allocator_Mode,
return nil, .Mode_Not_Implemented
case .Resize, .Resize_Non_Zeroed:
if old_memory == nil {
return aligned_alloc(size, alignment, nil, mode == .Resize)
}
return aligned_resize(old_memory, old_size, size, alignment, mode == .Resize)
case .Query_Features:
@@ -97,14 +109,14 @@ heap_allocator_proc :: proc(allocator_data: rawptr, mode: Allocator_Mode,
}
heap_alloc :: proc(size: int, zero_memory := true) -> rawptr {
heap_alloc :: proc "contextless" (size: int, zero_memory := true) -> rawptr {
return _heap_alloc(size, zero_memory)
}
heap_resize :: proc(ptr: rawptr, new_size: int) -> rawptr {
heap_resize :: proc "contextless" (ptr: rawptr, new_size: int) -> rawptr {
return _heap_resize(ptr, new_size)
}
heap_free :: proc(ptr: rawptr) {
heap_free :: proc "contextless" (ptr: rawptr) {
_heap_free(ptr)
}
+29
View File
@@ -0,0 +1,29 @@
#+build orca
#+private
package runtime
foreign {
@(link_name="malloc") _orca_malloc :: proc "c" (size: int) -> rawptr ---
@(link_name="calloc") _orca_calloc :: proc "c" (num, size: int) -> rawptr ---
@(link_name="free") _orca_free :: proc "c" (ptr: rawptr) ---
@(link_name="realloc") _orca_realloc :: proc "c" (ptr: rawptr, size: int) -> rawptr ---
}
_heap_alloc :: proc "contextless" (size: int, zero_memory := true) -> rawptr {
if size <= 0 {
return nil
}
if zero_memory {
return _orca_calloc(1, size)
} else {
return _orca_malloc(size)
}
}
_heap_resize :: proc "contextless" (ptr: rawptr, new_size: int) -> rawptr {
return _orca_realloc(ptr, new_size)
}
_heap_free :: proc "contextless" (ptr: rawptr) {
_orca_free(ptr)
}
+9 -6
View File
@@ -1,15 +1,18 @@
//+build js, wasi, freestanding, essence
//+private
#+build js, wasi, freestanding, essence
#+private
package runtime
_heap_alloc :: proc(size: int, zero_memory := true) -> rawptr {
_heap_alloc :: proc "contextless" (size: int, zero_memory := true) -> rawptr {
context = default_context()
unimplemented("base:runtime 'heap_alloc' procedure is not supported on this platform")
}
_heap_resize :: proc(ptr: rawptr, new_size: int) -> rawptr {
_heap_resize :: proc "contextless" (ptr: rawptr, new_size: int) -> rawptr {
context = default_context()
unimplemented("base:runtime 'heap_resize' procedure is not supported on this platform")
}
_heap_free :: proc(ptr: rawptr) {
_heap_free :: proc "contextless" (ptr: rawptr) {
context = default_context()
unimplemented("base:runtime 'heap_free' procedure is not supported on this platform")
}
}
+6 -6
View File
@@ -1,9 +1,9 @@
//+build linux, darwin, freebsd, openbsd, netbsd, haiku
//+private
#+build linux, darwin, freebsd, openbsd, netbsd, haiku
#+private
package runtime
when ODIN_OS == .Darwin {
foreign import libc "system:System.framework"
foreign import libc "system:System"
} else {
foreign import libc "system:c"
}
@@ -16,7 +16,7 @@ foreign libc {
@(link_name="realloc") _unix_realloc :: proc(ptr: rawptr, size: int) -> rawptr ---
}
_heap_alloc :: proc(size: int, zero_memory := true) -> rawptr {
_heap_alloc :: proc "contextless" (size: int, zero_memory := true) -> rawptr {
if size <= 0 {
return nil
}
@@ -27,12 +27,12 @@ _heap_alloc :: proc(size: int, zero_memory := true) -> rawptr {
}
}
_heap_resize :: proc(ptr: rawptr, new_size: int) -> rawptr {
_heap_resize :: proc "contextless" (ptr: rawptr, new_size: int) -> rawptr {
// NOTE: _unix_realloc doesn't guarantee new memory will be zeroed on
// POSIX platforms. Ensure your caller takes this into account.
return _unix_realloc(ptr, new_size)
}
_heap_free :: proc(ptr: rawptr) {
_heap_free :: proc "contextless" (ptr: rawptr) {
_unix_free(ptr)
}
+13 -5
View File
@@ -1,5 +1,7 @@
package runtime
import "../sanitizer"
foreign import kernel32 "system:Kernel32.lib"
@(private="file")
@@ -14,11 +16,14 @@ foreign kernel32 {
HeapFree :: proc(hHeap: rawptr, dwFlags: u32, lpMem: rawptr) -> b32 ---
}
_heap_alloc :: proc(size: int, zero_memory := true) -> rawptr {
_heap_alloc :: proc "contextless" (size: int, zero_memory := true) -> rawptr {
HEAP_ZERO_MEMORY :: 0x00000008
return HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY if zero_memory else 0, uint(size))
ptr := HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY if zero_memory else 0, uint(size))
// NOTE(lucas): asan not guarunteed to unpoison win32 heap out of the box, do it ourselves
sanitizer.address_unpoison(ptr, size)
return ptr
}
_heap_resize :: proc(ptr: rawptr, new_size: int) -> rawptr {
_heap_resize :: proc "contextless" (ptr: rawptr, new_size: int) -> rawptr {
if new_size == 0 {
_heap_free(ptr)
return nil
@@ -28,9 +33,12 @@ _heap_resize :: proc(ptr: rawptr, new_size: int) -> rawptr {
}
HEAP_ZERO_MEMORY :: 0x00000008
return HeapReAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, ptr, uint(new_size))
new_ptr := HeapReAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, ptr, uint(new_size))
// NOTE(lucas): asan not guarunteed to unpoison win32 heap out of the box, do it ourselves
sanitizer.address_unpoison(new_ptr, new_size)
return new_ptr
}
_heap_free :: proc(ptr: rawptr) {
_heap_free :: proc "contextless" (ptr: rawptr) {
if ptr == nil {
return
}
+484 -165
View File
@@ -1,3 +1,4 @@
#+vet !cast
package runtime
import "base:intrinsics"
@@ -7,15 +8,20 @@ IS_WASM :: ODIN_ARCH == .wasm32 || ODIN_ARCH == .wasm64p32
@(private)
RUNTIME_LINKAGE :: "strong" when (
(ODIN_USE_SEPARATE_MODULES ||
ODIN_USE_SEPARATE_MODULES ||
ODIN_BUILD_MODE == .Dynamic ||
!ODIN_NO_CRT) &&
!IS_WASM) else "internal"
!ODIN_NO_CRT) else "internal"
RUNTIME_REQUIRE :: false // !ODIN_TILDE
@(private)
__float16 :: f16 when __ODIN_LLVM_F16_SUPPORTED else u16
HAS_HARDWARE_SIMD :: false when (ODIN_ARCH == .amd64 || ODIN_ARCH == .i386) && !intrinsics.has_target_feature("sse2") else
false when (ODIN_ARCH == .arm64 || ODIN_ARCH == .arm32) && !intrinsics.has_target_feature("neon") else
false when (ODIN_ARCH == .wasm64p32 || ODIN_ARCH == .wasm32) && !intrinsics.has_target_feature("simd128") else
false when (ODIN_ARCH == .riscv64) && !intrinsics.has_target_feature("v") else
true
@(private)
byte_slice :: #force_inline proc "contextless" (data: rawptr, len: int) -> []byte #no_bounds_check {
@@ -29,7 +35,7 @@ is_power_of_two_int :: #force_inline proc "contextless" (x: int) -> bool {
return (x & (x-1)) == 0
}
align_forward_int :: #force_inline proc(ptr, align: int) -> int {
align_forward_int :: #force_inline proc "odin" (ptr, align: int) -> int {
assert(is_power_of_two_int(align))
p := ptr
@@ -47,7 +53,7 @@ is_power_of_two_uint :: #force_inline proc "contextless" (x: uint) -> bool {
return (x & (x-1)) == 0
}
align_forward_uint :: #force_inline proc(ptr, align: uint) -> uint {
align_forward_uint :: #force_inline proc "odin" (ptr, align: uint) -> uint {
assert(is_power_of_two_uint(align))
p := ptr
@@ -65,7 +71,7 @@ is_power_of_two_uintptr :: #force_inline proc "contextless" (x: uintptr) -> bool
return (x & (x-1)) == 0
}
align_forward_uintptr :: #force_inline proc(ptr, align: uintptr) -> uintptr {
align_forward_uintptr :: #force_inline proc "odin" (ptr, align: uintptr) -> uintptr {
assert(is_power_of_two_uintptr(align))
p := ptr
@@ -117,31 +123,31 @@ mem_copy_non_overlapping :: proc "contextless" (dst, src: rawptr, len: int) -> r
DEFAULT_ALIGNMENT :: 2*align_of(rawptr)
mem_alloc_bytes :: #force_inline proc(size: int, alignment: int = DEFAULT_ALIGNMENT, allocator := context.allocator, loc := #caller_location) -> ([]byte, Allocator_Error) {
if size == 0 {
return nil, nil
}
if allocator.procedure == nil {
mem_alloc_bytes :: #force_no_inline proc(size: int, alignment: int = DEFAULT_ALIGNMENT, allocator := context.allocator, loc := #caller_location) -> ([]byte, Allocator_Error) {
assert(is_power_of_two_int(alignment), "Alignment must be a power of two", loc)
if size == 0 || allocator.procedure == nil{
return nil, nil
}
return allocator.procedure(allocator.data, .Alloc, size, alignment, nil, 0, loc)
}
mem_alloc :: #force_inline proc(size: int, alignment: int = DEFAULT_ALIGNMENT, allocator := context.allocator, loc := #caller_location) -> ([]byte, Allocator_Error) {
mem_alloc :: #force_no_inline proc(size: int, alignment: int = DEFAULT_ALIGNMENT, allocator := context.allocator, loc := #caller_location) -> ([]byte, Allocator_Error) {
assert(is_power_of_two_int(alignment), "Alignment must be a power of two", loc)
if size == 0 || allocator.procedure == nil {
return nil, nil
}
return allocator.procedure(allocator.data, .Alloc, size, alignment, nil, 0, loc)
}
mem_alloc_non_zeroed :: #force_inline proc(size: int, alignment: int = DEFAULT_ALIGNMENT, allocator := context.allocator, loc := #caller_location) -> ([]byte, Allocator_Error) {
mem_alloc_non_zeroed :: #force_no_inline proc(size: int, alignment: int = DEFAULT_ALIGNMENT, allocator := context.allocator, loc := #caller_location) -> ([]byte, Allocator_Error) {
assert(is_power_of_two_int(alignment), "Alignment must be a power of two", loc)
if size == 0 || allocator.procedure == nil {
return nil, nil
}
return allocator.procedure(allocator.data, .Alloc_Non_Zeroed, size, alignment, nil, 0, loc)
}
mem_free :: #force_inline proc(ptr: rawptr, allocator := context.allocator, loc := #caller_location) -> Allocator_Error {
mem_free :: #force_no_inline proc(ptr: rawptr, allocator := context.allocator, loc := #caller_location) -> Allocator_Error {
if ptr == nil || allocator.procedure == nil {
return nil
}
@@ -149,7 +155,7 @@ mem_free :: #force_inline proc(ptr: rawptr, allocator := context.allocator, loc
return err
}
mem_free_with_size :: #force_inline proc(ptr: rawptr, byte_count: int, allocator := context.allocator, loc := #caller_location) -> Allocator_Error {
mem_free_with_size :: #force_no_inline proc(ptr: rawptr, byte_count: int, allocator := context.allocator, loc := #caller_location) -> Allocator_Error {
if ptr == nil || allocator.procedure == nil {
return nil
}
@@ -157,7 +163,7 @@ mem_free_with_size :: #force_inline proc(ptr: rawptr, byte_count: int, allocator
return err
}
mem_free_bytes :: #force_inline proc(bytes: []byte, allocator := context.allocator, loc := #caller_location) -> Allocator_Error {
mem_free_bytes :: #force_no_inline proc(bytes: []byte, allocator := context.allocator, loc := #caller_location) -> Allocator_Error {
if bytes == nil || allocator.procedure == nil {
return nil
}
@@ -166,14 +172,15 @@ mem_free_bytes :: #force_inline proc(bytes: []byte, allocator := context.allocat
}
mem_free_all :: #force_inline proc(allocator := context.allocator, loc := #caller_location) -> (err: Allocator_Error) {
mem_free_all :: #force_no_inline proc(allocator := context.allocator, loc := #caller_location) -> (err: Allocator_Error) {
if allocator.procedure != nil {
_, err = allocator.procedure(allocator.data, .Free_All, 0, 0, nil, 0, loc)
}
return
}
_mem_resize :: #force_inline proc(ptr: rawptr, old_size, new_size: int, alignment: int = DEFAULT_ALIGNMENT, allocator := context.allocator, should_zero: bool, loc := #caller_location) -> (data: []byte, err: Allocator_Error) {
_mem_resize :: #force_no_inline proc(ptr: rawptr, old_size, new_size: int, alignment: int = DEFAULT_ALIGNMENT, allocator := context.allocator, should_zero: bool, loc := #caller_location) -> (data: []byte, err: Allocator_Error) {
assert(is_power_of_two_int(alignment), "Alignment must be a power of two", loc)
if allocator.procedure == nil {
return nil, nil
}
@@ -215,162 +222,304 @@ _mem_resize :: #force_inline proc(ptr: rawptr, old_size, new_size: int, alignmen
}
mem_resize :: proc(ptr: rawptr, old_size, new_size: int, alignment: int = DEFAULT_ALIGNMENT, allocator := context.allocator, loc := #caller_location) -> (data: []byte, err: Allocator_Error) {
assert(is_power_of_two_int(alignment), "Alignment must be a power of two", loc)
return _mem_resize(ptr, old_size, new_size, alignment, allocator, true, loc)
}
non_zero_mem_resize :: proc(ptr: rawptr, old_size, new_size: int, alignment: int = DEFAULT_ALIGNMENT, allocator := context.allocator, loc := #caller_location) -> (data: []byte, err: Allocator_Error) {
assert(is_power_of_two_int(alignment), "Alignment must be a power of two", loc)
return _mem_resize(ptr, old_size, new_size, alignment, allocator, false, loc)
}
conditional_mem_zero :: proc "contextless" (data: rawptr, n_: int) #no_bounds_check {
// When acquiring memory from the OS for the first time it's likely that the
// OS already gives the zero page mapped multiple times for the request. The
// actual allocation does not have physical pages allocated to it until those
// pages are written to which causes a page-fault. This is often called COW
// (Copy on Write)
//
// You do not want to actually zero out memory in this case because it would
// cause a bunch of page faults decreasing the speed of allocations and
// increase the amount of actual resident physical memory used.
//
// Instead a better technique is to check if memory is zerored before zeroing
// it. This turns out to be an important optimization in practice, saving
// nearly half (or more) the amount of physical memory used by an application.
// This is why every implementation of calloc in libc does this optimization.
//
// It may seem counter-intuitive but most allocations in an application are
// wasted and never used. When you consider something like a [dynamic]T which
// always doubles in capacity on resize but you rarely ever actually use the
// full capacity of a dynamic array it means you have a lot of resident waste
// if you actually zeroed the remainder of the memory.
//
// Keep in mind the OS is already guaranteed to give you zeroed memory by
// mapping in this zero page multiple times so in the best case there is no
// need to actually zero anything. As for testing all this memory for a zero
// value, it costs nothing because the the same zero page is used for the
// whole allocation and will exist in L1 cache for the entire zero checking
// process.
if n_ <= 0 {
return
}
n := uint(n_)
n_words := n / size_of(uintptr)
p_words := ([^]uintptr)(data)[:n_words]
p_bytes := ([^]byte)(data)[size_of(uintptr) * n_words:n]
for &p_word in p_words {
if p_word != 0 {
p_word = 0
}
}
for &p_byte in p_bytes {
if p_byte != 0 {
p_byte = 0
}
}
}
memory_equal :: proc "contextless" (x, y: rawptr, n: int) -> bool {
switch {
case n == 0: return true
case x == y: return true
}
a, b := ([^]byte)(x), ([^]byte)(y)
length := uint(n)
a, b := cast([^]byte)x, cast([^]byte)y
for i := uint(0); i < length; i += 1 {
n := uint(n)
i := uint(0)
m := uint(0)
if n >= 8 {
when HAS_HARDWARE_SIMD {
// Avoid using 256-bit SIMD on platforms where its emulation is
// likely to be less than ideal.
when ODIN_ARCH == .amd64 && intrinsics.has_target_feature("avx2") {
m = n / 32 * 32
for /**/; i < m; i += 32 {
load_a := intrinsics.unaligned_load(cast(^#simd[32]u8)&a[i])
load_b := intrinsics.unaligned_load(cast(^#simd[32]u8)&b[i])
ne := intrinsics.simd_lanes_ne(load_a, load_b)
if intrinsics.simd_reduce_or(ne) != 0 {
return false
}
}
}
}
m = (n-i) / 16 * 16
for /**/; i < m; i += 16 {
load_a := intrinsics.unaligned_load(cast(^#simd[16]u8)&a[i])
load_b := intrinsics.unaligned_load(cast(^#simd[16]u8)&b[i])
ne := intrinsics.simd_lanes_ne(load_a, load_b)
if intrinsics.simd_reduce_or(ne) != 0 {
return false
}
}
m = (n-i) / size_of(uintptr) * size_of(uintptr)
for /**/; i < m; i += size_of(uintptr) {
if intrinsics.unaligned_load(cast(^uintptr)&a[i]) != intrinsics.unaligned_load(cast(^uintptr)&b[i]) {
return false
}
}
}
for /**/; i < n; i += 1 {
if a[i] != b[i] {
return false
}
}
return true
/*
when size_of(uint) == 8 {
if word_length := length >> 3; word_length != 0 {
for _ in 0..<word_length {
if intrinsics.unaligned_load((^u64)(a)) != intrinsics.unaligned_load((^u64)(b)) {
return false
}
a = a[size_of(u64):]
b = b[size_of(u64):]
}
}
if length & 4 != 0 {
if intrinsics.unaligned_load((^u32)(a)) != intrinsics.unaligned_load((^u32)(b)) {
return false
}
a = a[size_of(u32):]
b = b[size_of(u32):]
}
if length & 2 != 0 {
if intrinsics.unaligned_load((^u16)(a)) != intrinsics.unaligned_load((^u16)(b)) {
return false
}
a = a[size_of(u16):]
b = b[size_of(u16):]
}
if length & 1 != 0 && a[0] != b[0] {
return false
}
return true
} else {
if word_length := length >> 2; word_length != 0 {
for _ in 0..<word_length {
if intrinsics.unaligned_load((^u32)(a)) != intrinsics.unaligned_load((^u32)(b)) {
return false
}
a = a[size_of(u32):]
b = b[size_of(u32):]
}
}
length &= 3
if length != 0 {
for i in 0..<length {
if a[i] != b[i] {
return false
}
}
}
return true
}
*/
}
memory_compare :: proc "contextless" (a, b: rawptr, n: int) -> int #no_bounds_check {
memory_compare :: proc "contextless" (x, y: rawptr, n: int) -> int #no_bounds_check {
switch {
case a == b: return 0
case a == nil: return -1
case b == nil: return +1
case x == y: return 0
case x == nil: return -1
case y == nil: return +1
}
a, b := cast([^]byte)x, cast([^]byte)y
n := uint(n)
i := uint(0)
m := uint(0)
x := uintptr(a)
y := uintptr(b)
n := uintptr(n)
SU :: size_of(uintptr)
fast := n/SU + 1
offset := (fast-1)*SU
curr_block := uintptr(0)
if n < SU {
fast = 0
}
for /**/; curr_block < fast; curr_block += 1 {
va := (^uintptr)(x + curr_block * size_of(uintptr))^
vb := (^uintptr)(y + curr_block * size_of(uintptr))^
if va ~ vb != 0 {
for pos := curr_block*SU; pos < n; pos += 1 {
a := (^byte)(x+pos)^
b := (^byte)(y+pos)^
if a ~ b != 0 {
return -1 if (int(a) - int(b)) < 0 else +1
when HAS_HARDWARE_SIMD {
when ODIN_ARCH == .amd64 && intrinsics.has_target_feature("avx2") {
m = n / 32 * 32
for /**/; i < m; i += 32 {
load_a := intrinsics.unaligned_load(cast(^#simd[32]u8)&a[i])
load_b := intrinsics.unaligned_load(cast(^#simd[32]u8)&b[i])
comparison := intrinsics.simd_lanes_ne(load_a, load_b)
if intrinsics.simd_reduce_or(comparison) != 0 {
sentinel: #simd[32]u8 = u8(0xFF)
indices := intrinsics.simd_indices(#simd[32]u8)
index_select := intrinsics.simd_select(comparison, indices, sentinel)
index_reduce := cast(uint)intrinsics.simd_reduce_min(index_select)
return -1 if a[i+index_reduce] < b[i+index_reduce] else +1
}
}
}
}
for /**/; offset < n; offset += 1 {
a := (^byte)(x+offset)^
b := (^byte)(y+offset)^
if a ~ b != 0 {
return -1 if (int(a) - int(b)) < 0 else +1
m = (n-i) / 16 * 16
for /**/; i < m; i += 16 {
load_a := intrinsics.unaligned_load(cast(^#simd[16]u8)&a[i])
load_b := intrinsics.unaligned_load(cast(^#simd[16]u8)&b[i])
comparison := intrinsics.simd_lanes_ne(load_a, load_b)
if intrinsics.simd_reduce_or(comparison) != 0 {
sentinel: #simd[16]u8 = u8(0xFF)
indices := intrinsics.simd_indices(#simd[16]u8)
index_select := intrinsics.simd_select(comparison, indices, sentinel)
index_reduce := cast(uint)intrinsics.simd_reduce_min(index_select)
return -1 if a[i+index_reduce] < b[i+index_reduce] else +1
}
}
// 64-bit SIMD is faster than using a `uintptr` to detect a difference then
// re-iterating with the byte-by-byte loop, at least on AMD64.
m = (n-i) / 8 * 8
for /**/; i < m; i += 8 {
load_a := intrinsics.unaligned_load(cast(^#simd[8]u8)&a[i])
load_b := intrinsics.unaligned_load(cast(^#simd[8]u8)&b[i])
comparison := intrinsics.simd_lanes_ne(load_a, load_b)
if intrinsics.simd_reduce_or(comparison) != 0 {
sentinel: #simd[8]u8 = u8(0xFF)
indices := intrinsics.simd_indices(#simd[8]u8)
index_select := intrinsics.simd_select(comparison, indices, sentinel)
index_reduce := cast(uint)intrinsics.simd_reduce_min(index_select)
return -1 if a[i+index_reduce] < b[i+index_reduce] else +1
}
}
for /**/; i < n; i += 1 {
if a[i] ~ b[i] != 0 {
return -1 if int(a[i]) - int(b[i]) < 0 else +1
}
}
return 0
}
memory_compare_zero :: proc "contextless" (a: rawptr, n: int) -> int #no_bounds_check {
x := uintptr(a)
n := uintptr(n)
n := uint(n)
i := uint(0)
m := uint(0)
SU :: size_of(uintptr)
fast := n/SU + 1
offset := (fast-1)*SU
curr_block := uintptr(0)
if n < SU {
fast = 0
// Because we're comparing against zero, we never return -1, as that would
// indicate the compared value is less than zero.
//
// Note that a zero return value here means equality.
bytes := ([^]u8)(a)
if n >= 8 {
when HAS_HARDWARE_SIMD {
when ODIN_ARCH == .amd64 && intrinsics.has_target_feature("avx2") {
scanner32: #simd[32]u8
m = n / 32 * 32
for /**/; i < m; i += 32 {
load := intrinsics.unaligned_load(cast(^#simd[32]u8)&bytes[i])
ne := intrinsics.simd_lanes_ne(scanner32, load)
if intrinsics.simd_reduce_or(ne) > 0 {
return 1
}
}
}
}
scanner16: #simd[16]u8
m = (n-i) / 16 * 16
for /**/; i < m; i += 16 {
load := intrinsics.unaligned_load(cast(^#simd[16]u8)&bytes[i])
ne := intrinsics.simd_lanes_ne(scanner16, load)
if intrinsics.simd_reduce_or(ne) != 0 {
return 1
}
}
m = (n-i) / size_of(uintptr) * size_of(uintptr)
for /**/; i < m; i += size_of(uintptr) {
if intrinsics.unaligned_load(cast(^uintptr)&bytes[i]) != 0 {
return 1
}
}
}
for /**/; curr_block < fast; curr_block += 1 {
va := (^uintptr)(x + curr_block * size_of(uintptr))^
if va ~ 0 != 0 {
for pos := curr_block*SU; pos < n; pos += 1 {
a := (^byte)(x+pos)^
if a ~ 0 != 0 {
return -1 if int(a) < 0 else +1
for /**/; i < n; i += 1 {
if bytes[i] != 0 {
return 1
}
}
return 0
}
memory_prefix_length :: proc "contextless" (x, y: rawptr, n: int) -> (idx: int) #no_bounds_check {
switch {
case x == y: return n
case x == nil: return 0
case y == nil: return 0
}
a, b := cast([^]byte)x, cast([^]byte)y
n := uint(n)
i := uint(0)
m := uint(0)
when HAS_HARDWARE_SIMD {
when ODIN_ARCH == .amd64 && intrinsics.has_target_feature("avx2") {
m = n / 32 * 32
for /**/; i < m; i += 32 {
load_a := intrinsics.unaligned_load(cast(^#simd[32]u8)&a[i])
load_b := intrinsics.unaligned_load(cast(^#simd[32]u8)&b[i])
comparison := intrinsics.simd_lanes_ne(load_a, load_b)
if intrinsics.simd_reduce_or(comparison) != 0 {
sentinel: #simd[32]u8 = u8(0xFF)
indices := intrinsics.simd_indices(#simd[32]u8)
index_select := intrinsics.simd_select(comparison, indices, sentinel)
index_reduce := cast(uint)intrinsics.simd_reduce_min(index_select)
return int(i + index_reduce)
}
}
}
}
for /**/; offset < n; offset += 1 {
a := (^byte)(x+offset)^
if a ~ 0 != 0 {
return -1 if int(a) < 0 else +1
m = (n-i) / 16 * 16
for /**/; i < m; i += 16 {
load_a := intrinsics.unaligned_load(cast(^#simd[16]u8)&a[i])
load_b := intrinsics.unaligned_load(cast(^#simd[16]u8)&b[i])
comparison := intrinsics.simd_lanes_ne(load_a, load_b)
if intrinsics.simd_reduce_or(comparison) != 0 {
sentinel: #simd[16]u8 = u8(0xFF)
indices := intrinsics.simd_indices(#simd[16]u8)
index_select := intrinsics.simd_select(comparison, indices, sentinel)
index_reduce := cast(uint)intrinsics.simd_reduce_min(index_select)
return int(i + index_reduce)
}
}
return 0
// 64-bit SIMD is faster than using a `uintptr` to detect a difference then
// re-iterating with the byte-by-byte loop, at least on AMD64.
m = (n-i) / 8 * 8
for /**/; i < m; i += 8 {
load_a := intrinsics.unaligned_load(cast(^#simd[8]u8)&a[i])
load_b := intrinsics.unaligned_load(cast(^#simd[8]u8)&b[i])
comparison := intrinsics.simd_lanes_ne(load_a, load_b)
if intrinsics.simd_reduce_or(comparison) != 0 {
sentinel: #simd[8]u8 = u8(0xFF)
indices := intrinsics.simd_indices(#simd[8]u8)
index_select := intrinsics.simd_select(comparison, indices, sentinel)
index_reduce := cast(uint)intrinsics.simd_reduce_min(index_select)
return int(i + index_reduce)
}
}
for /**/; i < n; i += 1 {
if a[i] ~ b[i] != 0 {
return int(i)
}
}
return int(n)
}
string_eq :: proc "contextless" (lhs, rhs: string) -> bool {
@@ -393,12 +542,40 @@ string_cmp :: proc "contextless" (a, b: string) -> int {
return ret
}
string16_eq :: proc "contextless" (lhs, rhs: string16) -> bool {
x := transmute(Raw_String16)lhs
y := transmute(Raw_String16)rhs
if x.len != y.len {
return false
}
return #force_inline memory_equal(x.data, y.data, x.len*size_of(u16))
}
string16_cmp :: proc "contextless" (a, b: string16) -> int {
x := transmute(Raw_String16)a
y := transmute(Raw_String16)b
ret := memory_compare(x.data, y.data, min(x.len, y.len)*size_of(u16))
if ret == 0 && x.len != y.len {
return -1 if x.len < y.len else +1
}
return ret
}
string_ne :: #force_inline proc "contextless" (a, b: string) -> bool { return !string_eq(a, b) }
string_lt :: #force_inline proc "contextless" (a, b: string) -> bool { return string_cmp(a, b) < 0 }
string_gt :: #force_inline proc "contextless" (a, b: string) -> bool { return string_cmp(a, b) > 0 }
string_le :: #force_inline proc "contextless" (a, b: string) -> bool { return string_cmp(a, b) <= 0 }
string_ge :: #force_inline proc "contextless" (a, b: string) -> bool { return string_cmp(a, b) >= 0 }
string16_ne :: #force_inline proc "contextless" (a, b: string16) -> bool { return !string16_eq(a, b) }
string16_lt :: #force_inline proc "contextless" (a, b: string16) -> bool { return string16_cmp(a, b) < 0 }
string16_gt :: #force_inline proc "contextless" (a, b: string16) -> bool { return string16_cmp(a, b) > 0 }
string16_le :: #force_inline proc "contextless" (a, b: string16) -> bool { return string16_cmp(a, b) <= 0 }
string16_ge :: #force_inline proc "contextless" (a, b: string16) -> bool { return string16_cmp(a, b) >= 0 }
cstring_len :: proc "contextless" (s: cstring) -> int {
p0 := uintptr((^byte)(s))
p := p0
@@ -408,6 +585,16 @@ cstring_len :: proc "contextless" (s: cstring) -> int {
return int(p - p0)
}
cstring16_len :: proc "contextless" (s: cstring16) -> int {
p := ([^]u16)(s)
n := 0
for p != nil && p[0] != 0 {
p = p[1:]
n += 1
}
return n
}
cstring_to_string :: proc "contextless" (s: cstring) -> string {
if s == nil {
return ""
@@ -417,6 +604,15 @@ cstring_to_string :: proc "contextless" (s: cstring) -> string {
return transmute(string)Raw_String{ptr, n}
}
cstring16_to_string16 :: proc "contextless" (s: cstring16) -> string16 {
if s == nil {
return ""
}
ptr := (^u16)(s)
n := cstring16_len(s)
return transmute(string16)Raw_String16{ptr, n}
}
cstring_eq :: proc "contextless" (lhs, rhs: cstring) -> bool {
x := ([^]byte)(lhs)
@@ -459,6 +655,46 @@ cstring_gt :: #force_inline proc "contextless" (a, b: cstring) -> bool { return
cstring_le :: #force_inline proc "contextless" (a, b: cstring) -> bool { return cstring_cmp(a, b) <= 0 }
cstring_ge :: #force_inline proc "contextless" (a, b: cstring) -> bool { return cstring_cmp(a, b) >= 0 }
cstring16_eq :: proc "contextless" (lhs, rhs: cstring16) -> bool {
x := ([^]u16)(lhs)
y := ([^]u16)(rhs)
if x == y {
return true
}
if (x == nil) ~ (y == nil) {
return false
}
xn := cstring16_len(lhs)
yn := cstring16_len(rhs)
if xn != yn {
return false
}
return #force_inline memory_equal(x, y, xn*size_of(u16))
}
cstring16_cmp :: proc "contextless" (lhs, rhs: cstring16) -> int {
x := ([^]u16)(lhs)
y := ([^]u16)(rhs)
if x == y {
return 0
}
if (x == nil) ~ (y == nil) {
return -1 if x == nil else +1
}
xn := cstring16_len(lhs)
yn := cstring16_len(rhs)
ret := memory_compare(x, y, min(xn, yn)*size_of(u16))
if ret == 0 && xn != yn {
return -1 if xn < yn else +1
}
return ret
}
cstring16_ne :: #force_inline proc "contextless" (a, b: cstring16) -> bool { return !cstring16_eq(a, b) }
cstring16_lt :: #force_inline proc "contextless" (a, b: cstring16) -> bool { return cstring16_cmp(a, b) < 0 }
cstring16_gt :: #force_inline proc "contextless" (a, b: cstring16) -> bool { return cstring16_cmp(a, b) > 0 }
cstring16_le :: #force_inline proc "contextless" (a, b: cstring16) -> bool { return cstring16_cmp(a, b) <= 0 }
cstring16_ge :: #force_inline proc "contextless" (a, b: cstring16) -> bool { return cstring16_cmp(a, b) >= 0 }
complex32_eq :: #force_inline proc "contextless" (a, b: complex32) -> bool { return real(a) == real(b) && imag(a) == imag(b) }
complex32_ne :: #force_inline proc "contextless" (a, b: complex32) -> bool { return real(a) != real(b) || imag(a) != imag(b) }
@@ -480,10 +716,10 @@ quaternion256_eq :: #force_inline proc "contextless" (a, b: quaternion256) -> bo
quaternion256_ne :: #force_inline proc "contextless" (a, b: quaternion256) -> bool { return real(a) != real(b) || imag(a) != imag(b) || jmag(a) != jmag(b) || kmag(a) != kmag(b) }
string_decode_rune :: #force_inline proc "contextless" (s: string) -> (rune, int) {
string_decode_rune :: proc "contextless" (s: string) -> (rune, int) {
// NOTE(bill): Duplicated here to remove dependency on package unicode/utf8
@static accept_sizes := [256]u8{
@(static, rodata) accept_sizes := [256]u8{
0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, // 0x00-0x0f
0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, // 0x10-0x1f
0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, // 0x20-0x2f
@@ -504,7 +740,7 @@ string_decode_rune :: #force_inline proc "contextless" (s: string) -> (rune, int
}
Accept_Range :: struct {lo, hi: u8}
@static accept_ranges := [5]Accept_Range{
@(static, rodata) accept_ranges := [5]Accept_Range{
{0x80, 0xbf},
{0xa0, 0xbf},
{0x80, 0x9f},
@@ -594,6 +830,68 @@ string_decode_last_rune :: proc "contextless" (s: string) -> (rune, int) {
return r, size
}
string16_decode_rune :: proc "contextless" (s: string16) -> (rune, int) {
REPLACEMENT_CHAR :: '\ufffd'
_surr1 :: 0xd800
_surr2 :: 0xdc00
_surr3 :: 0xe000
_surr_self :: 0x10000
r := rune(REPLACEMENT_CHAR)
if len(s) < 1 {
return r, 0
}
w := 1
switch c := s[0]; {
case c < _surr1, _surr3 <= c:
r = rune(c)
case _surr1 <= c && c < _surr2 && 1 < len(s) &&
_surr2 <= s[1] && s[1] < _surr3:
r1, r2 := rune(c), rune(s[1])
if _surr1 <= r1 && r1 < _surr2 && _surr2 <= r2 && r2 < _surr3 {
r = (r1-_surr1)<<10 | (r2 - _surr2) + _surr_self
}
w += 1
}
return r, w
}
string16_decode_last_rune :: proc "contextless" (s: string16) -> (rune, int) {
REPLACEMENT_CHAR :: '\ufffd'
_surr1 :: 0xd800
_surr2 :: 0xdc00
_surr3 :: 0xe000
_surr_self :: 0x10000
r := rune(REPLACEMENT_CHAR)
if len(s) < 1 {
return r, 0
}
n := len(s)-1
c := s[n]
w := 1
if _surr2 <= c && c < _surr3 {
if n >= 1 {
r1 := rune(s[n-1])
r2 := rune(c)
if _surr1 <= r1 && r1 < _surr2 {
r = (r1-_surr1)<<10 | (r2 - _surr2) + _surr_self
}
w = 2
}
} else if c < _surr1 || _surr3 <= c {
r = rune(c)
}
return r, w
}
abs_complex32 :: #force_inline proc "contextless" (x: complex32) -> f16 {
p, q := abs(real(x)), abs(imag(x))
if p < q {
@@ -642,21 +940,24 @@ abs_quaternion256 :: #force_inline proc "contextless" (x: quaternion256) -> f64
quo_complex32 :: proc "contextless" (n, m: complex32) -> complex32 {
e, f: f16
nr, ni := f32(real(n)), f32(imag(n))
mr, mi := f32(real(m)), f32(imag(m))
if abs(real(m)) >= abs(imag(m)) {
ratio := imag(m) / real(m)
denom := real(m) + ratio*imag(m)
e = (real(n) + imag(n)*ratio) / denom
f = (imag(n) - real(n)*ratio) / denom
e, f: f32
if abs(mr) >= abs(mi) {
ratio := mi / mr
denom := mr + ratio*mi
e = (nr + ni*ratio) / denom
f = (ni - nr*ratio) / denom
} else {
ratio := real(m) / imag(m)
denom := imag(m) + ratio*real(m)
e = (real(n)*ratio + imag(n)) / denom
f = (imag(n)*ratio - real(n)) / denom
ratio := mr / mi
denom := mi + ratio*mr
e = (nr*ratio + ni) / denom
f = (ni*ratio - nr) / denom
}
return complex(e, f)
return complex(f16(e), f16(f))
}
@@ -697,15 +998,15 @@ quo_complex128 :: proc "contextless" (n, m: complex128) -> complex128 {
}
mul_quaternion64 :: proc "contextless" (q, r: quaternion64) -> quaternion64 {
q0, q1, q2, q3 := real(q), imag(q), jmag(q), kmag(q)
r0, r1, r2, r3 := real(r), imag(r), jmag(r), kmag(r)
q0, q1, q2, q3 := f32(real(q)), f32(imag(q)), f32(jmag(q)), f32(kmag(q))
r0, r1, r2, r3 := f32(real(r)), f32(imag(r)), f32(jmag(r)), f32(kmag(r))
t0 := r0*q0 - r1*q1 - r2*q2 - r3*q3
t1 := r0*q1 + r1*q0 - r2*q3 + r3*q2
t2 := r0*q2 + r1*q3 + r2*q0 - r3*q1
t3 := r0*q3 - r1*q2 + r2*q1 + r3*q0
return quaternion(w=t0, x=t1, y=t2, z=t3)
return quaternion(w=f16(t0), x=f16(t1), y=f16(t2), z=f16(t3))
}
mul_quaternion128 :: proc "contextless" (q, r: quaternion128) -> quaternion128 {
@@ -733,8 +1034,8 @@ mul_quaternion256 :: proc "contextless" (q, r: quaternion256) -> quaternion256 {
}
quo_quaternion64 :: proc "contextless" (q, r: quaternion64) -> quaternion64 {
q0, q1, q2, q3 := real(q), imag(q), jmag(q), kmag(q)
r0, r1, r2, r3 := real(r), imag(r), jmag(r), kmag(r)
q0, q1, q2, q3 := f32(real(q)), f32(imag(q)), f32(jmag(q)), f32(kmag(q))
r0, r1, r2, r3 := f32(real(r)), f32(imag(r)), f32(jmag(r)), f32(kmag(r))
invmag2 := 1.0 / (r0*r0 + r1*r1 + r2*r2 + r3*r3)
@@ -743,7 +1044,7 @@ quo_quaternion64 :: proc "contextless" (q, r: quaternion64) -> quaternion64 {
t2 := (r0*q2 - r1*q3 - r2*q0 + r3*q1) * invmag2
t3 := (r0*q3 + r1*q2 + r2*q1 - r3*q0) * invmag2
return quaternion(w=t0, x=t1, y=t2, z=t3)
return quaternion(w=f16(t0), x=f16(t1), y=f16(t2), z=f16(t3))
}
quo_quaternion128 :: proc "contextless" (q, r: quaternion128) -> quaternion128 {
@@ -875,9 +1176,6 @@ extendhfsf2 :: proc "c" (value: __float16) -> f32 {
@(link_name="__floattidf", linkage=RUNTIME_LINKAGE, require=RUNTIME_REQUIRE)
floattidf :: proc "c" (a: i128) -> f64 {
when IS_WASM {
return 0
} else {
DBL_MANT_DIG :: 53
if a == 0 {
return 0.0
@@ -917,14 +1215,10 @@ when IS_WASM {
fb[0] = u32(a) // mantissa-low
return transmute(f64)fb
}
}
@(link_name="__floattidf_unsigned", linkage=RUNTIME_LINKAGE, require=RUNTIME_REQUIRE)
floattidf_unsigned :: proc "c" (a: u128) -> f64 {
when IS_WASM {
return 0
} else {
DBL_MANT_DIG :: 53
if a == 0 {
return 0.0
@@ -962,7 +1256,6 @@ when IS_WASM {
fb[0] = u32(a) // mantissa-low
return transmute(f64)fb
}
}
@@ -1012,26 +1305,44 @@ modti3 :: proc "c" (a, b: i128) -> i128 {
bn := (b ~ s_b) - s_b
r: u128 = ---
_ = udivmod128(transmute(u128)an, transmute(u128)bn, &r)
return (transmute(i128)r ~ s_a) - s_a
_ = udivmod128(u128(an), u128(bn), &r)
return (i128(r) ~ s_a) - s_a
}
@(link_name="__divmodti4", linkage=RUNTIME_LINKAGE, require=RUNTIME_REQUIRE)
divmodti4 :: proc "c" (a, b: i128, rem: ^i128) -> i128 {
u := udivmod128(transmute(u128)a, transmute(u128)b, cast(^u128)rem)
return transmute(i128)u
s_a := a >> (128 - 1) // -1 if negative or 0
s_b := b >> (128 - 1)
an := (a ~ s_a) - s_a // absolute
bn := (b ~ s_b) - s_b
s_b ~= s_a // quotient sign
u_s_b := u128(s_b)
u_s_a := u128(s_a)
r: u128 = ---
u := i128((udivmodti4(u128(an), u128(bn), &r) ~ u_s_b) - u_s_b) // negate if negative
rem^ = i128((r ~ u_s_a) - u_s_a)
return u
}
@(link_name="__divti3", linkage=RUNTIME_LINKAGE, require=RUNTIME_REQUIRE)
divti3 :: proc "c" (a, b: i128) -> i128 {
u := udivmodti4(transmute(u128)a, transmute(u128)b, nil)
return transmute(i128)u
s_a := a >> (128 - 1) // -1 if negative or 0
s_b := b >> (128 - 1)
an := (a ~ s_a) - s_a // absolute
bn := (b ~ s_b) - s_b
s_a ~= s_b // quotient sign
u_s_a := u128(s_a)
return i128((udivmodti4(u128(an), u128(bn), nil) ~ u_s_a) - u_s_a) // negate if negative
}
@(link_name="__fixdfti", linkage=RUNTIME_LINKAGE, require=RUNTIME_REQUIRE)
fixdfti :: proc(a: u64) -> i128 {
fixdfti :: proc "c" (a: u64) -> i128 {
significandBits :: 52
typeWidth :: (size_of(u64)*8)
exponentBits :: (typeWidth - significandBits - 1)
@@ -1090,3 +1401,11 @@ __read_bits :: proc "contextless" (dst, src: [^]byte, offset: uintptr, size: uin
dst[j>>3] |= the_bit<<(j&7)
}
}
when .Address in ODIN_SANITIZER_FLAGS {
foreign {
@(require)
__asan_unpoison_memory_region :: proc "system" (address: rawptr, size: uint) ---
}
}
+4
View File
@@ -5,3 +5,7 @@ _OS_Errno :: distinct int
stderr_write :: proc "contextless" (data: []byte) -> (int, _OS_Errno) {
return _stderr_write(data)
}
exit :: proc "contextless" (code: int) -> ! {
_exit(code)
}
+11 -3
View File
@@ -1,5 +1,5 @@
//+build freebsd, openbsd, netbsd
//+private
#+build freebsd, openbsd, netbsd
#+private
package runtime
foreign import libc "system:c"
@@ -9,7 +9,7 @@ foreign libc {
@(link_name="write")
_unix_write :: proc(fd: i32, buf: rawptr, size: int) -> int ---
when ODIN_OS == .NetBSD {
when ODIN_OS == .NetBSD || ODIN_OS == .OpenBSD {
@(link_name="__errno") __error :: proc() -> ^i32 ---
} else {
__error :: proc() -> ^i32 ---
@@ -24,3 +24,11 @@ _stderr_write :: proc "contextless" (data: []byte) -> (int, _OS_Errno) {
}
return int(ret), 0
}
_exit :: proc "contextless" (code: int) -> ! {
@(default_calling_convention="c")
foreign libc {
exit :: proc(status: i32) -> ! ---
}
exit(i32(code))
}
+30 -7
View File
@@ -1,15 +1,38 @@
//+build darwin
//+private
#+build darwin
#+private
package runtime
import "base:intrinsics"
_stderr_write :: proc "contextless" (data: []byte) -> (int, _OS_Errno) {
WRITE :: 0x2000004
STDERR :: 2
ret := intrinsics.syscall(WRITE, STDERR, uintptr(raw_data(data)), uintptr(len(data)))
if ret < 0 {
return 0, _OS_Errno(-ret)
when ODIN_NO_CRT {
WRITE :: 0x2000004
ret := intrinsics.syscall(WRITE, STDERR, uintptr(raw_data(data)), uintptr(len(data)))
if ret < 0 {
return 0, _OS_Errno(-ret)
}
return int(ret), 0
} else {
foreign {
write :: proc(handle: i32, buffer: [^]byte, count: uint) -> int ---
__error :: proc() -> ^i32 ---
}
if ret := write(STDERR, raw_data(data), len(data)); ret >= 0 {
return int(ret), 0
}
return 0, _OS_Errno(__error()^)
}
return int(ret), 0
}
foreign import libc "system:System"
_exit :: proc "contextless" (code: int) -> ! {
@(default_calling_convention="c")
foreign libc {
exit :: proc(status: i32) -> ! ---
}
exit(i32(code))
}
+6 -2
View File
@@ -1,8 +1,12 @@
//+build freestanding
//+private
#+build freestanding
#+private
package runtime
// TODO(bill): reimplement `os.write`
_stderr_write :: proc "contextless" (data: []byte) -> (int, _OS_Errno) {
return 0, -1
}
_exit :: proc "contextless" (code: int) -> ! {
trap()
}
+8 -2
View File
@@ -1,5 +1,5 @@
//+build haiku
//+private
#+build haiku
#+private
package runtime
foreign import libc "system:c"
@@ -19,3 +19,9 @@ _stderr_write :: proc "contextless" (data: []byte) -> (int, _OS_Errno) {
}
return int(ret), 0
}
_exit :: proc "contextless" (code: int) -> ! {
trap()
}
+7 -2
View File
@@ -1,5 +1,5 @@
//+build js
//+private
#+build js
#+private
package runtime
foreign import "odin_env"
@@ -11,3 +11,8 @@ _stderr_write :: proc "contextless" (data: []byte) -> (int, _OS_Errno) {
write(1, data)
return len(data), 0
}
_exit :: proc "contextless" (code: int) -> ! {
trap()
}
+17 -1
View File
@@ -1,4 +1,4 @@
//+private
#+private
package runtime
import "base:intrinsics"
@@ -12,6 +12,8 @@ _stderr_write :: proc "contextless" (data: []byte) -> (int, _OS_Errno) {
SYS_write :: uintptr(4)
} else when ODIN_ARCH == .arm32 {
SYS_write :: uintptr(4)
} else when ODIN_ARCH == .riscv64 {
SYS_write :: uintptr(64)
}
stderr :: 2
@@ -22,3 +24,17 @@ _stderr_write :: proc "contextless" (data: []byte) -> (int, _OS_Errno) {
}
return ret, 0
}
_exit :: proc "contextless" (code: int) -> ! {
SYS_exit_group ::
231 when ODIN_ARCH == .amd64 else
248 when ODIN_ARCH == .arm32 else
94 when ODIN_ARCH == .arm64 else
252 when ODIN_ARCH == .i386 else
94 when ODIN_ARCH == .riscv64 else
0
intrinsics.syscall(uintptr(SYS_exit_group), uintptr(i32(code)))
unreachable()
}
+48
View File
@@ -0,0 +1,48 @@
#+build orca
#+private
package runtime
import "base:intrinsics"
// Constants allowing to specify the level of logging verbosity.
log_level :: enum u32 {
// Only errors are logged.
ERROR = 0,
// Only warnings and errors are logged.
WARNING = 1,
// All messages are logged.
INFO = 2,
COUNT = 3,
}
@(default_calling_convention="c", link_prefix="oc_")
foreign {
abort_ext :: proc(file: cstring, function: cstring, line: i32, fmt: cstring, #c_vararg args: ..any) -> ! ---
assert_fail :: proc(file: cstring, function: cstring, line: i32, src: cstring, fmt: cstring, #c_vararg args: ..any) -> ! ---
log_ext :: proc(level: log_level, function: cstring, file: cstring, line: i32, fmt: cstring, #c_vararg args: ..any) ---
}
// NOTE: This is all pretty gross, don't look.
// WASM is single threaded so this should be fine.
orca_stderr_buffer: [4096]byte
orca_stderr_buffer_idx: int
_stderr_write :: proc "contextless" (data: []byte) -> (int, _OS_Errno) {
for b in data {
orca_stderr_buffer[orca_stderr_buffer_idx] = b
orca_stderr_buffer_idx += 1
if b == '\n' || orca_stderr_buffer_idx == len(orca_stderr_buffer)-1 {
log_ext(.ERROR, "", "", 0, cstring(raw_data(orca_stderr_buffer[:orca_stderr_buffer_idx])))
orca_stderr_buffer_idx = 0
}
}
return len(data), 0
}
_exit :: proc "contextless" (code: int) -> ! {
trap()
}
+57 -5
View File
@@ -1,11 +1,63 @@
//+build wasi
//+private
#+build wasi
#+private
package runtime
import "core:sys/wasm/wasi"
foreign import wasi "wasi_snapshot_preview1"
@(default_calling_convention="contextless")
foreign wasi {
fd_write :: proc(
fd: i32,
iovs: [][]byte,
n: ^uint,
) -> u16 ---
@(private="file")
args_sizes_get :: proc(
num_of_args: ^uint,
size_of_args: ^uint,
) -> u16 ---
@(private="file")
args_get :: proc(
argv: [^]cstring,
argv_buf: [^]byte,
) -> u16 ---
@(private="file")
proc_exit :: proc(rval: u32) -> ! ---
}
_stderr_write :: proc "contextless" (data: []byte) -> (int, _OS_Errno) {
data_iovec := (wasi.ciovec_t)(data)
n, err := wasi.fd_write(1, {data_iovec})
n: uint
err := fd_write(1, {data}, &n)
return int(n), _OS_Errno(err)
}
_wasi_setup_args :: proc() {
num_of_args, size_of_args: uint
if errno := args_sizes_get(&num_of_args, &size_of_args); errno != 0 {
return
}
err: Allocator_Error
if args__, err = make([]cstring, num_of_args); err != nil {
return
}
args_buf: []byte
if args_buf, err = make([]byte, size_of_args); err != nil {
delete(args__)
return
}
if errno := args_get(raw_data(args__), raw_data(args_buf)); errno != 0 {
delete(args__)
delete(args_buf)
}
}
_exit :: proc "contextless" (code: int) -> ! {
proc_exit(u32(code))
}
+8 -2
View File
@@ -1,5 +1,5 @@
//+build windows
//+private
#+build windows
#+private
package runtime
foreign import kernel32 "system:Kernel32.lib"
@@ -14,6 +14,8 @@ foreign kernel32 {
SetHandleInformation :: proc(hObject: rawptr, dwMask: u32, dwFlags: u32) -> b32 ---
WriteFile :: proc(hFile: rawptr, lpBuffer: rawptr, nNumberOfBytesToWrite: u32, lpNumberOfBytesWritten: ^u32, lpOverlapped: rawptr) -> b32 ---
GetLastError :: proc() -> u32 ---
ExitProcess :: proc(code: u32) -> ! ---
}
_stderr_write :: proc "contextless" (data: []byte) -> (n: int, err: _OS_Errno) #no_bounds_check {
@@ -49,3 +51,7 @@ _stderr_write :: proc "contextless" (data: []byte) -> (n: int, err: _OS_Errno) #
n = int(total_write)
return
}
_exit :: proc "contextless" (code: int) -> ! {
ExitProcess(u32(code))
}
+14 -18
View File
@@ -262,7 +262,7 @@ print_typeid :: #force_no_inline proc "contextless" (id: typeid) {
}
}
@(optimization_mode="size")
@(optimization_mode="favor_size")
print_type :: #force_no_inline proc "contextless" (ti: ^Type_Info) {
if ti == nil {
print_string("nil")
@@ -293,7 +293,14 @@ print_type :: #force_no_inline proc "contextless" (ti: ^Type_Info) {
print_string("quaternion")
print_u64(u64(8*ti.size))
case Type_Info_String:
if info.is_cstring {
print_byte('c')
}
print_string("string")
switch info.encoding {
case .UTF_8: /**/
case .UTF_16: print_string("16")
}
case Type_Info_Boolean:
switch ti.id {
case bool: print_string("bool")
@@ -401,15 +408,16 @@ print_type :: #force_no_inline proc "contextless" (ti: ^Type_Info) {
}
print_string("struct ")
if info.is_packed { print_string("#packed ") }
if info.is_raw_union { print_string("#raw_union ") }
if info.custom_align {
if .packed in info.flags { print_string("#packed ") }
if .raw_union in info.flags { print_string("#raw_union ") }
// if .no_copy in info.flags { print_string("#no_copy ") }
if .align in info.flags {
print_string("#align(")
print_u64(u64(ti.align))
print_string(") ")
}
print_byte('{')
for name, i in info.names {
for name, i in info.names[:info.field_count] {
if i > 0 { print_string(", ") }
print_string(name)
print_string(": ")
@@ -469,7 +477,7 @@ print_type :: #force_no_inline proc "contextless" (ti: ^Type_Info) {
print_string("bit_field ")
print_type(info.backing_type)
print_string(" {")
for name, i in info.names {
for name, i in info.names[:info.field_count] {
if i > 0 { print_string(", ") }
print_string(name)
print_string(": ")
@@ -485,18 +493,6 @@ print_type :: #force_no_inline proc "contextless" (ti: ^Type_Info) {
print_u64(u64(info.count))
print_byte(']')
print_type(info.elem)
case Type_Info_Relative_Pointer:
print_string("#relative(")
print_type(info.base_integer)
print_string(") ")
print_type(info.pointer)
case Type_Info_Relative_Multi_Pointer:
print_string("#relative(")
print_type(info.base_integer)
print_string(") ")
print_type(info.pointer)
case Type_Info_Matrix:
print_string("matrix[")
+1 -1
View File
@@ -25,7 +25,7 @@ when ODIN_NO_CRT && ODIN_OS == .Windows {
RtlMoveMemory(dst, src, len)
return dst
}
} else when ODIN_NO_CRT || (ODIN_ARCH == .wasm32 || ODIN_ARCH == .wasm64p32) {
} else when ODIN_NO_CRT || (ODIN_OS != .Orca && (ODIN_ARCH == .wasm32 || ODIN_ARCH == .wasm64p32)) {
// NOTE: on wasm, calls to these procs are generated (by LLVM) with type `i32` instead of `int`.
//
// NOTE: `#any_int` is also needed, because calls that we generate (and package code)
+48 -13
View File
@@ -1,21 +1,56 @@
//+private
#+private
package runtime
foreign import "system:Foundation.framework"
@(priority_index=-1e5)
foreign import ObjC "system:objc"
@(priority_index=-1e6)
foreign import libSystem "system:System"
import "base:intrinsics"
objc_id :: ^intrinsics.objc_object
objc_id :: ^intrinsics.objc_object
objc_Class :: ^intrinsics.objc_class
objc_SEL :: ^intrinsics.objc_selector
objc_SEL :: ^intrinsics.objc_selector
objc_Ivar :: ^intrinsics.objc_ivar
objc_BOOL :: bool
foreign Foundation {
objc_lookUpClass :: proc "c" (name: cstring) -> objc_Class ---
sel_registerName :: proc "c" (name: cstring) -> objc_SEL ---
objc_allocateClassPair :: proc "c" (superclass: objc_Class, name: cstring, extraBytes: uint) -> objc_Class ---
objc_msgSend :: proc "c" (self: objc_id, op: objc_SEL, #c_vararg args: ..any) ---
objc_msgSend_fpret :: proc "c" (self: objc_id, op: objc_SEL, #c_vararg args: ..any) -> f64 ---
objc_msgSend_fp2ret :: proc "c" (self: objc_id, op: objc_SEL, #c_vararg args: ..any) -> complex128 ---
objc_msgSend_stret :: proc "c" (self: objc_id, op: objc_SEL, #c_vararg args: ..any) ---
objc_super :: struct {
receiver: objc_id,
super_class: objc_Class,
}
objc_IMP :: proc "c" (object: objc_id, sel: objc_SEL, #c_vararg args: ..any) -> objc_id
foreign ObjC {
sel_registerName :: proc "c" (name: cstring) -> objc_SEL ---
objc_msgSend :: proc "c" (self: objc_id, op: objc_SEL, #c_vararg args: ..any) ---
objc_msgSend_fpret :: proc "c" (self: objc_id, op: objc_SEL, #c_vararg args: ..any) -> f64 ---
objc_msgSend_fp2ret :: proc "c" (self: objc_id, op: objc_SEL, #c_vararg args: ..any) -> complex128 ---
objc_msgSend_stret :: proc "c" (self: objc_id, op: objc_SEL, #c_vararg args: ..any) ---
// See: https://github.com/opensource-apple/objc4/blob/cd5e62a5597ea7a31dccef089317abb3a661c154/runtime/objc-abi.h#L111
objc_msgSendSuper2 :: proc "c" (super: rawptr, op: objc_SEL, #c_vararg args: ..any) -> objc_id ---
objc_msgSendSuper2_stret :: proc "c" (super: ^objc_super, op: objc_SEL, #c_vararg args: ..any) ---
objc_lookUpClass :: proc "c" (name: cstring) -> objc_Class ---
objc_allocateClassPair :: proc "c" (superclass: objc_Class, name: cstring, extraBytes: uint) -> objc_Class ---
objc_registerClassPair :: proc "c" (cls : objc_Class) ---
class_addMethod :: proc "c" (cls: objc_Class, name: objc_SEL, imp: objc_IMP, types: cstring) -> objc_BOOL ---
class_addIvar :: proc "c" (cls: objc_Class, name: cstring, size: uint, alignment: u8, types: cstring) -> objc_BOOL ---
class_getInstanceVariable :: proc "c" (cls : objc_Class, name: cstring) -> objc_Ivar ---
class_getInstanceSize :: proc "c" (cls : objc_Class) -> uint ---
class_getSuperclass :: proc "c" (cls : objc_Class) -> objc_Class ---
ivar_getOffset :: proc "c" (v: objc_Ivar) -> uintptr ---
object_getClass :: proc "c" (obj: objc_id) -> objc_Class ---
}
foreign libSystem {
_NSConcreteGlobalBlock: intrinsics.objc_class
_NSConcreteStackBlock: intrinsics.objc_class
_Block_object_assign :: proc "c" (rawptr, rawptr, i32) ---
_Block_object_dispose :: proc "c" (rawptr, i32) ---
}
+3 -3
View File
@@ -1,10 +1,10 @@
//+build js
#+build js
package runtime
init_default_context_for_js: Context
@(init, private="file")
init_default_context :: proc() {
init_default_context_for_js = context
init_default_context :: proc "contextless" () {
__init_context(&init_default_context_for_js)
}
@(export)
+57 -14
View File
@@ -1,4 +1,4 @@
//+build wasm32, wasm64p32
#+build wasm32, wasm64p32
package runtime
@(private="file")
@@ -14,33 +14,57 @@ ti_uint :: struct #raw_union {
}
@(link_name="__ashlti3", linkage="strong")
__ashlti3 :: proc "contextless" (la, ha: u64, b_: u32) -> i128 {
bits_in_dword :: size_of(u32)*8
b := u32(b_)
__ashlti3 :: proc "contextless" (a: i128, b: u32) -> i128 {
bits :: 64
input, result: ti_int
input.lo, input.hi = la, ha
if b & bits_in_dword != 0 {
input: ti_int = ---
result: ti_int = ---
input.all = a
if b & bits != 0 {
result.lo = 0
result.hi = input.lo << (b-bits_in_dword)
result.hi = input.lo << (b-bits)
} else {
if b == 0 {
return input.all
return a
}
result.lo = input.lo<<b
result.hi = (input.hi<<b) | (input.lo>>(bits_in_dword-b))
result.hi = (input.hi<<b) | (input.lo>>(bits-b))
}
return result.all
}
__ashlti3_unsigned :: proc "contextless" (a: u128, b: u32) -> u128 {
return cast(u128)__ashlti3(cast(i128)a, b)
}
@(link_name="__mulddi3", linkage="strong")
__mulddi3 :: proc "contextless" (a, b: u64) -> i128 {
r: ti_int
bits :: 32
mask :: ~u64(0) >> bits
r.lo = (a & mask) * (b & mask)
t := r.lo >> bits
r.lo &= mask
t += (a >> bits) * (b & mask)
r.lo += (t & mask) << bits
r.hi = t >> bits
t = r.lo >> bits
r.lo &= mask
t += (b >> bits) * (a & mask)
r.lo += (t & mask) << bits
r.hi += t >> bits
r.hi += (a >> bits) * (b >> bits)
return r.all
}
@(link_name="__multi3", linkage="strong")
__multi3 :: proc "contextless" (la, ha, lb, hb: u64) -> i128 {
__multi3 :: proc "contextless" (a, b: i128) -> i128 {
x, y, r: ti_int
x.lo, x.hi = la, ha
y.lo, y.hi = lb, hb
r.all = i128(x.lo * y.lo) // TODO this is incorrect
x.all = a
y.all = b
r.all = __mulddi3(x.lo, y.lo)
r.hi += x.hi*y.lo + x.lo*y.hi
return r.all
}
@@ -52,3 +76,22 @@ udivti3 :: proc "c" (la, ha, lb, hb: u64) -> u128 {
b.lo, b.hi = lb, hb
return udivmodti4(a.all, b.all, nil)
}
@(link_name="__lshrti3", linkage="strong")
__lshrti3 :: proc "c" (a: i128, b: u32) -> i128 {
bits :: 64
input, result: ti_int
input.all = a
if b & bits != 0 {
result.hi = 0
result.lo = input.hi >> (b - bits)
} else if b == 0 {
return a
} else {
result.hi = input.hi >> b
result.lo = (input.hi << (bits - b)) | (input.lo >> b)
}
return result.all
}
+2 -2
View File
@@ -1,5 +1,5 @@
//+private
//+no-instrumentation
#+private
#+no-instrumentation
package runtime
foreign import kernel32 "system:Kernel32.lib"
+2 -2
View File
@@ -1,5 +1,5 @@
//+private
//+no-instrumentation
#+private
#+no-instrumentation
package runtime
@require foreign import "system:int64.lib"
+128
View File
@@ -0,0 +1,128 @@
package runtime
import "base:intrinsics"
@(require_results)
random_generator_read_bytes :: proc(rg: Random_Generator, p: []byte) -> bool {
if rg.procedure != nil {
rg.procedure(rg.data, .Read, p)
return true
}
return false
}
@(require_results)
random_generator_read_ptr :: proc(rg: Random_Generator, p: rawptr, len: uint) -> bool {
if rg.procedure != nil {
rg.procedure(rg.data, .Read, ([^]byte)(p)[:len])
return true
}
return false
}
@(require_results)
random_generator_query_info :: proc(rg: Random_Generator) -> (info: Random_Generator_Query_Info) {
if rg.procedure != nil {
rg.procedure(rg.data, .Query_Info, ([^]byte)(&info)[:size_of(info)])
}
return
}
random_generator_reset_bytes :: proc(rg: Random_Generator, p: []byte) {
if rg.procedure != nil {
rg.procedure(rg.data, .Reset, p)
}
}
random_generator_reset_u64 :: proc(rg: Random_Generator, p: u64) {
if rg.procedure != nil {
p := p
rg.procedure(rg.data, .Reset, ([^]byte)(&p)[:size_of(p)])
}
}
Default_Random_State :: struct {
state: u64,
inc: u64,
}
default_random_generator_proc :: proc(data: rawptr, mode: Random_Generator_Mode, p: []byte) {
@(require_results)
read_u64 :: proc "contextless" (r: ^Default_Random_State) -> u64 {
old_state := r.state
r.state = old_state * 6364136223846793005 + (r.inc|1)
xor_shifted := (((old_state >> 59) + 5) ~ old_state) * 12605985483714917081
rot := (old_state >> 59)
return (xor_shifted >> rot) | (xor_shifted << ((-rot) & 63))
}
@(thread_local)
global_rand_seed: Default_Random_State
init :: proc "contextless" (r: ^Default_Random_State, seed: u64) {
seed := seed
if seed == 0 {
seed = u64(intrinsics.read_cycle_counter())
}
r.state = 0
r.inc = (seed << 1) | 1
_ = read_u64(r)
r.state += seed
_ = read_u64(r)
}
r: ^Default_Random_State = ---
if data == nil {
r = &global_rand_seed
} else {
r = cast(^Default_Random_State)data
}
switch mode {
case .Read:
if r.state == 0 && r.inc == 0 {
init(r, 0)
}
switch len(p) {
case size_of(u64):
// Fast path for a 64-bit destination.
intrinsics.unaligned_store((^u64)(raw_data(p)), read_u64(r))
case:
// All other cases.
pos := i8(0)
val := u64(0)
for &v in p {
if pos == 0 {
val = read_u64(r)
pos = 8
}
v = byte(val)
val >>= 8
pos -= 1
}
}
case .Reset:
seed: u64
mem_copy_non_overlapping(&seed, raw_data(p), min(size_of(seed), len(p)))
init(r, seed)
case .Query_Info:
if len(p) != size_of(Random_Generator_Query_Info) {
return
}
info := (^Random_Generator_Query_Info)(raw_data(p))
info^ += {.Uniform, .Resettable}
}
}
@(require_results)
default_random_generator :: proc "contextless" (state: ^Default_Random_State = nil) -> Random_Generator {
return {
procedure = default_random_generator_proc,
data = state,
}
}
+41
View File
@@ -0,0 +1,41 @@
package runtime
Thread_Local_Cleaner_Odin :: #type proc "odin" ()
Thread_Local_Cleaner_Contextless :: #type proc "contextless" ()
Thread_Local_Cleaner :: union #shared_nil {Thread_Local_Cleaner_Odin, Thread_Local_Cleaner_Contextless}
@(private="file")
thread_local_cleaners: [8]Thread_Local_Cleaner
// Add a procedure that will be run at the end of a thread for the purpose of
// deallocating state marked as `thread_local`.
//
// Intended to be called in an `init` procedure of a package with
// dynamically-allocated memory that is stored in `thread_local` variables.
add_thread_local_cleaner :: proc "contextless" (p: Thread_Local_Cleaner) {
for &v in thread_local_cleaners {
if v == nil {
v = p
return
}
}
panic_contextless("There are no more thread-local cleaner slots available.")
}
// Run all of the thread-local cleaner procedures.
//
// Intended to be called by the internals of a threading API at the end of a
// thread's lifetime.
run_thread_local_cleaners :: proc "odin" () {
for p in thread_local_cleaners {
if p == nil {
break
}
switch v in p {
case Thread_Local_Cleaner_Odin: v()
case Thread_Local_Cleaner_Contextless: v()
}
}
}
+3 -3
View File
@@ -58,7 +58,7 @@ udivmod128 :: proc "c" (a, b: u128, rem: ^u128) -> u128 {
return u128(n[high] >> _ctz(d[high]))
}
sr = transmute(u32)(i32(_clz(d[high])) - i32(_clz(n[high])))
sr = u32(i32(_clz(d[high])) - i32(_clz(n[high])))
if sr > U64_BITS - 2 {
if rem != nil {
rem^ = a
@@ -107,7 +107,7 @@ udivmod128 :: proc "c" (a, b: u128, rem: ^u128) -> u128 {
r[low] = n[high] >> (sr - U64_BITS)
}
} else {
sr = transmute(u32)(i32(_clz(d[high])) - i32(_clz(n[high])))
sr = u32(i32(_clz(d[high])) - i32(_clz(n[high])))
if sr > U64_BITS - 1 {
if rem != nil {
@@ -143,7 +143,7 @@ udivmod128 :: proc "c" (a, b: u128, rem: ^u128) -> u128 {
r_all = transmute(u128)r
s := i128(b - r_all - 1) >> (U128_BITS - 1)
carry = u32(s & 1)
r_all -= b & transmute(u128)s
r_all -= b & u128(s)
r = transmute([2]u64)r_all
}
+22 -19
View File
@@ -1,4 +1,4 @@
//+build wasm32, wasm64p32
#+build wasm32, wasm64p32
package runtime
import "base:intrinsics"
@@ -7,20 +7,20 @@ import "base:intrinsics"
Port of emmalloc, modified for use in Odin.
Invariants:
- Per-allocation header overhead is 8 bytes, smallest allocated payload
amount is 8 bytes, and a multiple of 4 bytes.
- Acquired memory blocks are subdivided into disjoint regions that lie
next to each other.
- A region is either in used or free.
Used regions may be adjacent, and a used and unused region
may be adjacent, but not two unused ones - they would be
merged.
- Memory allocation takes constant time, unless the alloc needs to wasm_memory_grow()
or memory is very close to being exhausted.
- Free and used regions are managed inside "root regions", which are slabs
of memory acquired via wasm_memory_grow().
- Memory retrieved using wasm_memory_grow() can not be given back to the OS.
Therefore, frees are internal to the allocator.
- Per-allocation header overhead is 8 bytes, smallest allocated payload
amount is 8 bytes, and a multiple of 4 bytes.
- Acquired memory blocks are subdivided into disjoint regions that lie
next to each other.
- A region is either in used or free.
Used regions may be adjacent, and a used and unused region
may be adjacent, but not two unused ones - they would be
merged.
- Memory allocation takes constant time, unless the alloc needs to wasm_memory_grow()
or memory is very close to being exhausted.
- Free and used regions are managed inside "root regions", which are slabs
of memory acquired via wasm_memory_grow().
- Memory retrieved using wasm_memory_grow() can not be given back to the OS.
Therefore, frees are internal to the allocator.
Copyright (c) 2010-2014 Emscripten authors, see AUTHORS file.
@@ -89,10 +89,12 @@ wasm_allocator_init :: proc(a: ^WASM_Allocator, alignment: uint = 8) {
global_default_wasm_allocator_data: WASM_Allocator
@(require_results)
default_wasm_allocator :: proc() -> Allocator {
return wasm_allocator(&global_default_wasm_allocator_data)
}
@(require_results)
wasm_allocator :: proc(a: ^WASM_Allocator) -> Allocator {
return {
data = a,
@@ -297,7 +299,8 @@ lock :: proc(a: ^WASM_Allocator) {
return
}
assert(intrinsics.wasm_memory_atomic_wait32((^u32)(&a.mu), u32(new_state), -1) != 0)
ret := intrinsics.wasm_memory_atomic_wait32((^u32)(&a.mu), u32(new_state), -1)
assert(ret != 0)
intrinsics.cpu_relax()
}
}
@@ -495,7 +498,7 @@ claim_more_memory :: proc(a: ^WASM_Allocator, num_bytes: uint) -> bool {
// we can just extend the spill.
spill_end := uintptr(raw_data(a.spill)) + uintptr(len(a.spill))
if spill_end == uintptr(raw_data(allocated)) {
raw_spill := transmute(^Raw_Slice)(&a.spill)
raw_spill := (^Raw_Slice)(&a.spill)
raw_spill.len += len(allocated)
} else {
// Otherwise, we have to "waste" the previous spill.
@@ -679,7 +682,7 @@ allocate_memory :: proc(a: ^WASM_Allocator, alignment: uint, size: uint, loc :=
// but we just had a stale bit set to mark a populated bucket.
// Reset the bit to update latest status so that we do not
// redundantly look at this bucket again.
a.free_region_buckets_used &= ~(BUCKET_BITMASK_T(1) << bucket_index)
a.free_region_buckets_used &~= BUCKET_BITMASK_T(1) << bucket_index
bucket_mask ~= 1
}
@@ -760,7 +763,7 @@ free :: proc(a: ^WASM_Allocator, ptr: rawptr, loc := #caller_location) {
defer unlock(a)
size := region.size
assert(region_is_in_use(region), "double free", loc=loc)
assert(region_is_in_use(region), "double free or corrupt region", loc=loc)
prev_region_size_field := ([^]uint)(region)[-1]
prev_region_size := prev_region_size_field & ~uint(FREE_REGION_FLAG)
+601
View File
@@ -0,0 +1,601 @@
#+no-instrumentation
package sanitizer
Address_Death_Callback :: #type proc "c" (pc: rawptr, bp: rawptr, sp: rawptr, addr: rawptr, is_write: i32, access_size: uint)
@(private="file")
ASAN_ENABLED :: .Address in ODIN_SANITIZER_FLAGS
@(private="file")
@(default_calling_convention="system")
foreign {
__asan_poison_memory_region :: proc(address: rawptr, size: uint) ---
__asan_unpoison_memory_region :: proc(address: rawptr, size: uint) ---
__sanitizer_set_death_callback :: proc(callback: Address_Death_Callback) ---
__asan_region_is_poisoned :: proc(begin: rawptr, size: uint) -> rawptr ---
__asan_address_is_poisoned :: proc(addr: rawptr) -> i32 ---
__asan_describe_address :: proc(addr: rawptr) ---
__asan_report_present :: proc() -> i32 ---
__asan_get_report_pc :: proc() -> rawptr ---
__asan_get_report_bp :: proc() -> rawptr ---
__asan_get_report_sp :: proc() -> rawptr ---
__asan_get_report_address :: proc() -> rawptr ---
__asan_get_report_access_type :: proc() -> i32 ---
__asan_get_report_access_size :: proc() -> uint ---
__asan_get_report_description :: proc() -> cstring ---
__asan_locate_address :: proc(addr: rawptr, name: rawptr, name_size: uint, region_address: ^rawptr, region_size: ^uint) -> cstring ---
__asan_get_alloc_stack :: proc(addr: rawptr, trace: rawptr, size: uint, thread_id: ^i32) -> uint ---
__asan_get_free_stack :: proc(addr: rawptr, trace: rawptr, size: uint, thread_id: ^i32) -> uint ---
__asan_get_shadow_mapping :: proc(shadow_scale: ^uint, shadow_offset: ^uint) ---
__asan_print_accumulated_stats :: proc() ---
__asan_get_current_fake_stack :: proc() -> rawptr ---
__asan_addr_is_in_fake_stack :: proc(fake_stack: rawptr, addr: rawptr, beg: ^rawptr, end: ^rawptr) -> rawptr ---
__asan_handle_no_return :: proc() ---
__asan_update_allocation_context :: proc(addr: rawptr) -> i32 ---
}
Address_Access_Type :: enum {
none,
read,
write,
}
Address_Located_Address :: struct {
category: string,
name: string,
region: []byte,
}
Address_Shadow_Mapping :: struct {
scale: uint,
offset: uint,
}
/*
Marks a slice as unaddressable
Code instrumented with `-sanitize:address` is forbidden from accessing any address
within the slice. This procedure is not thread-safe because no two threads can
poison or unpoison memory in the same memory region region simultaneously.
When asan is not enabled this procedure does nothing.
*/
@(no_sanitize_address)
address_poison_slice :: proc "contextless" (region: $T/[]$E) {
when ASAN_ENABLED {
__asan_poison_memory_region(raw_data(region), size_of(E) * len(region))
}
}
/*
Marks a slice as addressable
Code instrumented with `-sanitize:address` is allowed to access any address
within the slice again. This procedure is not thread-safe because no two threads
can poison or unpoison memory in the same memory region region simultaneously.
When asan is not enabled this procedure does nothing.
*/
@(no_sanitize_address)
address_unpoison_slice :: proc "contextless" (region: $T/[]$E) {
when ASAN_ENABLED {
__asan_unpoison_memory_region(raw_data(region), size_of(E) * len(region))
}
}
/*
Marks a pointer as unaddressable
Code instrumented with `-sanitize:address` is forbidden from accessing any address
within the region the pointer points to. This procedure is not thread-safe because no
two threads can poison or unpoison memory in the same memory region region simultaneously.
When asan is not enabled this procedure does nothing.
*/
@(no_sanitize_address)
address_poison_ptr :: proc "contextless" (ptr: ^$T) {
when ASAN_ENABLED {
__asan_poison_memory_region(ptr, size_of(T))
}
}
/*
Marks a pointer as addressable
Code instrumented with `-sanitize:address` is allowed to access any address
within the region the pointer points to again. This procedure is not thread-safe
because no two threads can poison or unpoison memory in the same memory region
region simultaneously.
When asan is not enabled this procedure does nothing.
*/
@(no_sanitize_address)
address_unpoison_ptr :: proc "contextless" (ptr: ^$T) {
when ASAN_ENABLED {
__asan_unpoison_memory_region(ptr, size_of(T))
}
}
/*
Marks the region covering `[ptr, ptr+len)` as unaddressable
Code instrumented with `-sanitize:address` is forbidden from accessing any address
within the region. This procedure is not thread-safe because no two threads can
poison or unpoison memory in the same memory region region simultaneously.
When asan is not enabled this procedure does nothing.
*/
@(no_sanitize_address)
address_poison_rawptr :: proc "contextless" (ptr: rawptr, len: int) {
when ASAN_ENABLED {
assert_contextless(len >= 0)
__asan_poison_memory_region(ptr, uint(len))
}
}
/*
Marks the region covering `[ptr, ptr+len)` as unaddressable
Code instrumented with `-sanitize:address` is forbidden from accessing any address
within the region. This procedure is not thread-safe because no two threads can
poison or unpoison memory in the same memory region region simultaneously.
When asan is not enabled this procedure does nothing.
*/
@(no_sanitize_address)
address_poison_rawptr_uint :: proc "contextless" (ptr: rawptr, len: uint) {
when ASAN_ENABLED {
__asan_poison_memory_region(ptr, len)
}
}
/*
Marks the region covering `[ptr, ptr+len)` as addressable
Code instrumented with `-sanitize:address` is allowed to access any address
within the region again. This procedure is not thread-safe because no two
threads can poison or unpoison memory in the same memory region region simultaneously.
When asan is not enabled this procedure does nothing.
*/
@(no_sanitize_address)
address_unpoison_rawptr :: proc "contextless" (ptr: rawptr, len: int) {
when ASAN_ENABLED {
assert_contextless(len >= 0)
__asan_unpoison_memory_region(ptr, uint(len))
}
}
/*
Marks the region covering `[ptr, ptr+len)` as addressable
Code instrumented with `-sanitize:address` is allowed to access any address
within the region again. This procedure is not thread-safe because no two
threads can poison or unpoison memory in the same memory region region simultaneously.
When asan is not enabled this procedure does nothing.
*/
@(no_sanitize_address)
address_unpoison_rawptr_uint :: proc "contextless" (ptr: rawptr, len: uint) {
when ASAN_ENABLED {
__asan_unpoison_memory_region(ptr, len)
}
}
address_poison :: proc {
address_poison_slice,
address_poison_ptr,
address_poison_rawptr,
address_poison_rawptr_uint,
}
address_unpoison :: proc {
address_unpoison_slice,
address_unpoison_ptr,
address_unpoison_rawptr,
address_unpoison_rawptr_uint,
}
/*
Registers a callback to be run when asan detects a memory error right before terminating
the process.
This can be used for logging and/or debugging purposes.
When asan is not enabled this procedure does nothing.
*/
@(no_sanitize_address)
address_set_death_callback :: proc "contextless" (callback: Address_Death_Callback) {
when ASAN_ENABLED {
__sanitizer_set_death_callback(callback)
}
}
/*
Checks if the memory region covered by the slice is poisoned.
If it is poisoned this procedure returns the address which would result
in an asan error.
When asan is not enabled this procedure returns `nil`.
*/
@(no_sanitize_address)
address_region_is_poisoned_slice :: proc "contextless" (region: $T/[]$E) -> rawptr {
when ASAN_ENABLED {
return __asan_region_is_poisoned(raw_data(region), size_of(E) * len(region))
} else {
return nil
}
}
/*
Checks if the memory region pointed to by the pointer is poisoned.
If it is poisoned this procedure returns the address which would result
in an asan error.
When asan is not enabled this procedure returns `nil`.
*/
@(no_sanitize_address)
address_region_is_poisoned_ptr :: proc "contextless" (ptr: ^$T) -> rawptr {
when ASAN_ENABLED {
return __asan_region_is_poisoned(ptr, size_of(T))
} else {
return nil
}
}
/*
Checks if the memory region covered by `[ptr, ptr+len)` is poisoned.
If it is poisoned this procedure returns the address which would result
in an asan error.
When asan is not enabled this procedure returns `nil`.
*/
@(no_sanitize_address)
address_region_is_poisoned_rawptr :: proc "contextless" (region: rawptr, len: int) -> rawptr {
when ASAN_ENABLED {
assert_contextless(len >= 0)
return __asan_region_is_poisoned(region, uint(len))
} else {
return nil
}
}
/*
Checks if the memory region covered by `[ptr, ptr+len)` is poisoned.
If it is poisoned this procedure returns the address which would result
in an asan error.
When asan is not enabled this procedure returns `nil`.
*/
@(no_sanitize_address)
address_region_is_poisoned_rawptr_uint :: proc "contextless" (region: rawptr, len: uint) -> rawptr {
when ASAN_ENABLED {
return __asan_region_is_poisoned(region, len)
} else {
return nil
}
}
address_region_is_poisoned :: proc {
address_region_is_poisoned_slice,
address_region_is_poisoned_ptr,
address_region_is_poisoned_rawptr,
address_region_is_poisoned_rawptr_uint,
}
/*
Checks if the address is poisoned.
If it is poisoned this procedure returns `true`, otherwise it returns
`false`.
When asan is not enabled this procedure returns `false`.
*/
@(no_sanitize_address)
address_is_poisoned :: proc "contextless" (address: rawptr) -> bool {
when ASAN_ENABLED {
return __asan_address_is_poisoned(address) != 0
} else {
return false
}
}
/*
Describes the sanitizer state for an address.
This procedure prints the description out to `stdout`.
When asan is not enabled this procedure does nothing.
*/
@(no_sanitize_address)
address_describe_address :: proc "contextless" (address: rawptr) {
when ASAN_ENABLED {
__asan_describe_address(address)
}
}
/*
Returns `true` if an asan error has occured, otherwise it returns
`false`.
When asan is not enabled this procedure returns `false`.
*/
@(no_sanitize_address)
address_report_present :: proc "contextless" () -> bool {
when ASAN_ENABLED {
return __asan_report_present() != 0
} else {
return false
}
}
/*
Returns the program counter register value of an asan error.
If no asan error has occurd `nil` is returned.
When asan is not enabled this procedure returns `nil`.
*/
@(no_sanitize_address)
address_get_report_pc :: proc "contextless" () -> rawptr {
when ASAN_ENABLED {
return __asan_get_report_pc()
} else {
return nil
}
}
/*
Returns the base pointer register value of an asan error.
If no asan error has occurd `nil` is returned.
When asan is not enabled this procedure returns `nil`.
*/
@(no_sanitize_address)
address_get_report_bp :: proc "contextless" () -> rawptr {
when ASAN_ENABLED {
return __asan_get_report_bp()
} else {
return nil
}
}
/*
Returns the stack pointer register value of an asan error.
If no asan error has occurd `nil` is returned.
When asan is not enabled this procedure returns `nil`.
*/
@(no_sanitize_address)
address_get_report_sp :: proc "contextless" () -> rawptr {
when ASAN_ENABLED {
return __asan_get_report_sp()
} else {
return nil
}
}
/*
Returns the report buffer address of an asan error.
If no asan error has occurd `nil` is returned.
When asan is not enabled this procedure returns `nil`.
*/
@(no_sanitize_address)
address_get_report_address :: proc "contextless" () -> rawptr {
when ASAN_ENABLED {
return __asan_get_report_address()
} else {
return nil
}
}
/*
Returns the address access type of an asan error.
If no asan error has occurd `.none` is returned.
When asan is not enabled this procedure returns `.none`.
*/
@(no_sanitize_address)
address_get_report_access_type :: proc "contextless" () -> Address_Access_Type {
when ASAN_ENABLED {
if ! address_report_present() {
return .none
}
return __asan_get_report_access_type() == 0 ? .read : .write
} else {
return .none
}
}
/*
Returns the access size of an asan error.
If no asan error has occurd `0` is returned.
When asan is not enabled this procedure returns `0`.
*/
@(no_sanitize_address)
address_get_report_access_size :: proc "contextless" () -> uint {
when ASAN_ENABLED {
return __asan_get_report_access_size()
} else {
return 0
}
}
/*
Returns the bug description of an asan error.
If no asan error has occurd an empty string is returned.
When asan is not enabled this procedure returns an empty string.
*/
@(no_sanitize_address)
address_get_report_description :: proc "contextless" () -> string {
when ASAN_ENABLED {
return string(__asan_get_report_description())
} else {
return ""
}
}
/*
Returns asan information about the address provided, writing the category into `data`.
The information provided include:
* The category of the address, i.e. stack, global, heap, etc.
* The name of the variable this address belongs to
* The memory region of the address
When asan is not enabled this procedure returns zero initialised values.
*/
@(no_sanitize_address)
address_locate_address :: proc "contextless" (addr: rawptr, data: []byte) -> Address_Located_Address {
when ASAN_ENABLED {
out_addr: rawptr
out_size: uint
str := __asan_locate_address(addr, raw_data(data), len(data), &out_addr, &out_size)
return { string(str), string(cstring(raw_data(data))), (cast([^]byte)out_addr)[:out_size] },
} else {
return { "", "", {} }
}
}
/*
Returns the allocation stack trace and thread id for a heap address.
The stack trace is filled into the `data` slice.
When asan is not enabled this procedure returns a zero initialised value.
*/
@(no_sanitize_address)
address_get_alloc_stack_trace :: proc "contextless" (addr: rawptr, data: []rawptr) -> ([]rawptr, int) {
when ASAN_ENABLED {
out_thread: i32
__asan_get_alloc_stack(addr, raw_data(data), len(data), &out_thread)
return data, int(out_thread)
} else {
return {}, 0
}
}
/*
Returns the free stack trace and thread id for a heap address.
The stack trace is filled into the `data` slice.
When asan is not enabled this procedure returns zero initialised values.
*/
@(no_sanitize_address)
address_get_free_stack_trace :: proc "contextless" (addr: rawptr, data: []rawptr) -> ([]rawptr, int) {
when ASAN_ENABLED {
out_thread: i32
__asan_get_free_stack(addr, raw_data(data), len(data), &out_thread)
return data, int(out_thread)
} else {
return {}, 0
}
}
/*
Returns the current asan shadow memory mapping.
When asan is not enabled this procedure returns a zero initialised value.
*/
@(no_sanitize_address)
address_get_shadow_mapping :: proc "contextless" () -> Address_Shadow_Mapping {
when ASAN_ENABLED {
result: Address_Shadow_Mapping
__asan_get_shadow_mapping(&result.scale, &result.offset)
return result
} else {
return {}
}
}
/*
Prints asan statistics to `stderr`
When asan is not enabled this procedure does nothing.
*/
@(no_sanitize_address)
address_print_accumulated_stats :: proc "contextless" () {
when ASAN_ENABLED {
__asan_print_accumulated_stats()
}
}
/*
Returns the address of the current fake stack used by asan.
This pointer can be then used for `address_is_in_fake_stack`.
When asan is not enabled this procedure returns `nil`.
*/
@(no_sanitize_address)
address_get_current_fake_stack :: proc "contextless" () -> rawptr {
when ASAN_ENABLED {
return __asan_get_current_fake_stack()
} else {
return nil
}
}
/*
Returns if an address belongs to a given fake stack and if so the region of the fake frame.
When asan is not enabled this procedure returns zero initialised values.
*/
@(no_sanitize_address)
address_is_in_fake_stack :: proc "contextless" (fake_stack: rawptr, addr: rawptr) -> ([]byte, bool) {
when ASAN_ENABLED {
begin: rawptr
end: rawptr
if __asan_addr_is_in_fake_stack(fake_stack, addr, &begin, &end) == nil {
return {}, false
}
return ((cast([^]byte)begin)[:uintptr(end)-uintptr(begin)]), true
} else {
return {}, false
}
}
/*
Performs shadow memory cleanup for the current thread before a procedure with no return is called
i.e. a procedure such as `panic` and `os.exit`.
When asan is not enabled this procedure does nothing.
*/
@(no_sanitize_address)
address_handle_no_return :: proc "contextless" () {
when ASAN_ENABLED {
__asan_handle_no_return()
}
}
/*
Updates the allocation stack trace for the given address.
Returns `true` if successful, otherwise it returns `false`.
When asan is not enabled this procedure returns `false`.
*/
@(no_sanitize_address)
address_update_allocation_context :: proc "contextless" (addr: rawptr) -> bool {
when ASAN_ENABLED {
return __asan_update_allocation_context(addr) != 0
} else {
return false
}
}
+38
View File
@@ -0,0 +1,38 @@
/*
The `sanitizer` package implements various procedures for interacting with sanitizers
from user code.
An odin project can be linked with various sanitizers to help identify various different
bugs. These sanitizers are:
## Address
Enabled with `-sanitize:address` when building an odin project.
The address sanitizer (asan) is a runtime memory error detector used to help find common memory
related bugs. Typically asan interacts with libc but Odin code can be marked up to interact
with the asan runtime to extend the memory error detection outside of libc using this package.
For more information about asan see: https://clang.llvm.org/docs/AddressSanitizer.html
Procedures can be made exempt from asan when marked up with @(no_sanitize_address)
## Memory
Enabled with `-sanitize:memory` when building an odin project.
The memory sanitizer is another runtime memory error detector with the sole purpose to catch the
use of uninitialized memory. This is not a very common bug in Odin as by default everything is
set to zero when initialised (ZII).
For more information about the memory sanitizer see: https://clang.llvm.org/docs/MemorySanitizer.html
## Thread
Enabled with `-sanitize:thread` when building an odin project.
The thread sanitizer is a runtime data race detector. It can be used to detect if multiple threads
are concurrently writing and accessing a memory location without proper syncronisation.
For more information about the thread sanitizer see: https://clang.llvm.org/docs/ThreadSanitizer.html
*/
package sanitizer
+74
View File
@@ -0,0 +1,74 @@
#+no-instrumentation
package sanitizer
@(private="file")
MSAN_ENABLED :: .Memory in ODIN_SANITIZER_FLAGS
@(private="file")
@(default_calling_convention="system")
foreign {
__msan_unpoison :: proc(addr: rawptr, size: uint) ---
}
/*
Marks a slice as fully initialized.
Code instrumented with `-sanitize:memory` will be permitted to access any
address within the slice as if it had already been initialized.
When msan is not enabled this procedure does nothing.
*/
memory_unpoison_slice :: proc "contextless" (region: $T/[]$E) {
when MSAN_ENABLED {
__msan_unpoison(raw_data(region), size_of(E) * len(region))
}
}
/*
Marks a pointer as fully initialized.
Code instrumented with `-sanitize:memory` will be permitted to access memory
within the region the pointer points to as if it had already been initialized.
When msan is not enabled this procedure does nothing.
*/
memory_unpoison_ptr :: proc "contextless" (ptr: ^$T) {
when MSAN_ENABLED {
__msan_unpoison(ptr, size_of(T))
}
}
/*
Marks the region covering `[ptr, ptr+len)` as fully initialized.
Code instrumented with `-sanitize:memory` will be permitted to access memory
within this range as if it had already been initialized.
When msan is not enabled this procedure does nothing.
*/
memory_unpoison_rawptr :: proc "contextless" (ptr: rawptr, len: int) {
when MSAN_ENABLED {
__msan_unpoison(ptr, uint(len))
}
}
/*
Marks the region covering `[ptr, ptr+len)` as fully initialized.
Code instrumented with `-sanitize:memory` will be permitted to access memory
within this range as if it had already been initialized.
When msan is not enabled this procedure does nothing.
*/
memory_unpoison_rawptr_uint :: proc "contextless" (ptr: rawptr, len: uint) {
when MSAN_ENABLED {
__msan_unpoison(ptr, len)
}
}
memory_unpoison :: proc {
memory_unpoison_slice,
memory_unpoison_ptr,
memory_unpoison_rawptr,
memory_unpoison_rawptr_uint,
}
+19
View File
@@ -0,0 +1,19 @@
Copyright (c) 2024 Epic Games Tools
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the “Software”), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
of the Software, and to permit persons to whom the Software is furnished to do
so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
BIN
View File
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
View File
Binary file not shown.
BIN
View File
Binary file not shown.
+53 -21
View File
@@ -4,12 +4,12 @@ setlocal EnableDelayedExpansion
where /Q cl.exe || (
set __VSCMD_ARG_NO_LOGO=1
for /f "tokens=*" %%i in ('"C:\Program Files (x86)\Microsoft Visual Studio\Installer\vswhere.exe" -latest -requires Microsoft.VisualStudio.Workload.NativeDesktop -property installationPath') do set VS=%%i
for /f "tokens=*" %%i in ('"C:\Program Files (x86)\Microsoft Visual Studio\Installer\vswhere.exe" -latest -products * -requires Microsoft.VisualStudio.Component.VC.Tools.x86.x64 -property installationPath') do set VS=%%i
if "!VS!" equ "" (
echo ERROR: Visual Studio installation not found
echo ERROR: MSVC installation not found
exit /b 1
)
call "!VS!\VC\Auxiliary\Build\vcvarsall.bat" amd64 || exit /b 1
call "!VS!\Common7\Tools\vsdevcmd.bat" -arch=x64 -host_arch=x64 || exit /b 1
)
if "%VSCMD_ARG_TGT_ARCH%" neq "x64" (
@@ -19,12 +19,27 @@ if "%VSCMD_ARG_TGT_ARCH%" neq "x64" (
)
)
for /f "usebackq tokens=1,2 delims=,=- " %%i in (`wmic os get LocalDateTime /value`) do @if %%i==LocalDateTime (
set CURR_DATE_TIME=%%j
where /Q git.exe || goto skip_git_hash
if not exist .git\ goto skip_git_hash
for /f "tokens=1,2" %%i IN ('git show "--pretty=%%cd %%h" "--date=format:%%Y-%%m-%%d" --no-patch --no-notes HEAD') do (
set CURR_DATE_TIME=%%i
set GIT_SHA=%%j
)
if %ERRORLEVEL% equ 0 (
goto have_git_hash_and_date
)
:skip_git_hash
pushd misc
cl /nologo get-date.c
for /f %%i in ('get-date') do (
set CURR_DATE_TIME=%%i
rem Don't set GIT_SHA
)
popd
:have_git_hash_and_date
set curr_year=%CURR_DATE_TIME:~0,4%
set curr_month=%CURR_DATE_TIME:~4,2%
set curr_month=%CURR_DATE_TIME:~5,2%
set curr_day=%CURR_DATE_TIME:~8,2%
:: Make sure this is a decent name and not generic
set exe_name=odin.exe
@@ -45,23 +60,32 @@ if "%2" == "1" (
set nightly=0
)
set odin_version_raw="dev-%curr_year%-%curr_month%"
set compiler_flags= -nologo -Oi -TP -fp:precise -Gm- -MP -FC -EHsc- -GR- -GF
set compiler_defines= -DODIN_VERSION_RAW=\"%odin_version_raw%\"
if not exist .git\ goto skip_git_hash
for /f "tokens=1,2" %%i IN ('git show "--pretty=%%cd %%h" "--date=format:%%Y-%%m" --no-patch --no-notes HEAD') do (
set odin_version_raw=dev-%%i
set GIT_SHA=%%j
if %release_mode% equ 0 (
set V1=%curr_year%
set V2=%curr_month%
set V3=%curr_day%
) else (
set V1=%curr_year%
set V2=%curr_month%
set V3=0
)
if %ERRORLEVEL% equ 0 set compiler_defines=%compiler_defines% -DGIT_SHA=\"%GIT_SHA%\"
:skip_git_hash
set V4=0
set odin_version_full="%V1%.%V2%.%V3%.%V4%"
set odin_version_raw="dev-%V1%-%V2%"
set compiler_flags= -nologo -Oi -TP -fp:precise -Gm- -MP -FC -EHsc- -GR- -GF
rem Parse source code as utf-8 even on shift-jis and other codepages
rem See https://learn.microsoft.com/en-us/cpp/build/reference/utf-8-set-source-and-executable-character-sets-to-utf-8?view=msvc-170
set compiler_flags= %compiler_flags% /utf-8
set compiler_defines= -DODIN_VERSION_RAW=\"%odin_version_raw%\" -DGIT_SHA=\"%GIT_SHA%\"
rem fileversion is defined as {Major,Minor,Build,Private: u16} so a bit limited
set rc_flags="-DGIT_SHA=%GIT_SHA% -DVP=dev-%V1%-%V2%:%GIT_SHA% nologo -DV1=%V1% -DV2=%V2% -DV3=%V3% -DV4=%V4% -DVF=%odin_version_full% -DNIGHTLY=%nightly%"
if %nightly% equ 1 set compiler_defines=%compiler_defines% -DNIGHTLY
if %release_mode% EQU 0 ( rem Debug
set compiler_flags=%compiler_flags% -Od -MDd -Z7
set rc_flags=%rc_flags% -D_DEBUG
) else ( rem Release
set compiler_flags=%compiler_flags% -O2 -MT -Z7
set compiler_defines=%compiler_defines% -DNO_ARRAY_BOUNDS_CHECK
@@ -79,6 +103,8 @@ set libs= ^
kernel32.lib ^
Synchronization.lib ^
bin\llvm\windows\LLVM-C.lib
set odin_res=misc\odin.res
set odin_rc=misc\odin.rc
rem DO NOT TOUCH!
rem THIS TILDE STUFF IS FOR DEVELOPMENT ONLY!
@@ -90,7 +116,7 @@ if %tilde_backend% EQU 1 (
rem DO NOT TOUCH!
set linker_flags= -incremental:no -opt:ref -subsystem:console
set linker_flags= -incremental:no -opt:ref -subsystem:console -MANIFEST:EMBED
if %release_mode% EQU 0 ( rem Debug
set linker_flags=%linker_flags% -debug /NATVIS:src\odin_compiler.natvis
@@ -99,19 +125,25 @@ if %release_mode% EQU 0 ( rem Debug
)
set compiler_settings=%compiler_includes% %compiler_flags% %compiler_warnings% %compiler_defines%
set linker_settings=%libs% %linker_flags%
set linker_settings=%libs% %odin_res% %linker_flags%
del *.pdb > NUL 2> NUL
del *.ilk > NUL 2> NUL
rc %rc_flags% %odin_rc%
cl %compiler_settings% "src\main.cpp" "src\libtommath.cpp" /link %linker_settings% -OUT:%exe_name%
if %errorlevel% neq 0 goto end_of_build
mt -nologo -inputresource:%exe_name%;#1 -manifest misc\odin.manifest -outputresource:%exe_name%;#1 -validate_manifest -identity:"odin, processorArchitecture=amd64, version=%odin_version_full%, type=win32"
if %errorlevel% neq 0 goto end_of_build
call build_vendor.bat
if %errorlevel% neq 0 goto end_of_build
rem If the demo doesn't run for you and your CPU is more than a decade old, try -microarch:native
if %release_mode% EQU 0 odin run examples/demo -- Hellope World
if %release_mode% EQU 0 odin run examples/demo -vet -strict-style -resource:examples/demo/demo.rc -- Hellope World
rem Many non-compiler devs seem to run debug build but don't realize.
if %release_mode% EQU 0 echo: & echo Debug compiler built. Note: run "build.bat release" if you want a faster, release mode compiler.
del *.obj > NUL 2> NUL
+46 -29
View File
@@ -6,38 +6,52 @@ set -eu
: ${LDFLAGS=}
: ${LLVM_CONFIG=}
CPPFLAGS="$CPPFLAGS -DODIN_VERSION_RAW=\"dev-$(date +"%Y-%m")\""
CXXFLAGS="$CXXFLAGS -std=c++14"
DISABLED_WARNINGS="-Wno-switch -Wno-macro-redefined -Wno-unused-value"
LDFLAGS="$LDFLAGS -pthread -lm -lstdc++"
LDFLAGS="$LDFLAGS -pthread -lm"
OS_ARCH="$(uname -m)"
OS_NAME="$(uname -s)"
if [ -d ".git" ] && [ -n "$(command -v git)" ]; then
GIT_SHA=$(git show --pretty='%h' --no-patch --no-notes HEAD)
GIT_DATE=$(git show "--pretty=%cd" "--date=format:%Y-%m" --no-patch --no-notes HEAD)
CPPFLAGS="$CPPFLAGS -DGIT_SHA=\"$GIT_SHA\""
else
GIT_DATE=$(date +"%Y-%m")
fi
CPPFLAGS="$CPPFLAGS -DODIN_VERSION_RAW=\"dev-$GIT_DATE\""
error() {
printf "ERROR: %s\n" "$1"
exit 1
}
# Brew advises people not to add llvm to their $PATH, so try and use brew to find it.
if [ -z "$LLVM_CONFIG" ] && [ -n "$(command -v brew)" ]; then
if [ -n "$(command -v $(brew --prefix llvm@21)/bin/llvm-config)" ]; then LLVM_CONFIG="$(brew --prefix llvm@21)/bin/llvm-config"
elif [ -n "$(command -v $(brew --prefix llvm@20)/bin/llvm-config)" ]; then LLVM_CONFIG="$(brew --prefix llvm@20)/bin/llvm-config"
elif [ -n "$(command -v $(brew --prefix llvm@19)/bin/llvm-config)" ]; then LLVM_CONFIG="$(brew --prefix llvm@19)/bin/llvm-config"
elif [ -n "$(command -v $(brew --prefix llvm@18)/bin/llvm-config)" ]; then LLVM_CONFIG="$(brew --prefix llvm@18)/bin/llvm-config"
elif [ -n "$(command -v $(brew --prefix llvm@17)/bin/llvm-config)" ]; then LLVM_CONFIG="$(brew --prefix llvm@17)/bin/llvm-config"
elif [ -n "$(command -v $(brew --prefix llvm@14)/bin/llvm-config)" ]; then LLVM_CONFIG="$(brew --prefix llvm@14)/bin/llvm-config"
fi
fi
if [ -z "$LLVM_CONFIG" ]; then
# darwin, linux, openbsd
if [ -n "$(command -v llvm-config-18)" ]; then LLVM_CONFIG="llvm-config-18"
if [ -n "$(command -v llvm-config-21)" ]; then LLVM_CONFIG="llvm-config-21"
elif [ -n "$(command -v llvm-config-20)" ]; then LLVM_CONFIG="llvm-config-20"
elif [ -n "$(command -v llvm-config-19)" ]; then LLVM_CONFIG="llvm-config-19"
elif [ -n "$(command -v llvm-config-18)" ]; then LLVM_CONFIG="llvm-config-18"
elif [ -n "$(command -v llvm-config-17)" ]; then LLVM_CONFIG="llvm-config-17"
elif [ -n "$(command -v llvm-config-14)" ]; then LLVM_CONFIG="llvm-config-14"
elif [ -n "$(command -v llvm-config-13)" ]; then LLVM_CONFIG="llvm-config-13"
elif [ -n "$(command -v llvm-config-12)" ]; then LLVM_CONFIG="llvm-config-12"
elif [ -n "$(command -v llvm-config-11)" ]; then LLVM_CONFIG="llvm-config-11"
# freebsd
elif [ -n "$(command -v llvm-config21)" ]; then LLVM_CONFIG="llvm-config21"
elif [ -n "$(command -v llvm-config20)" ]; then LLVM_CONFIG="llvm-config20"
elif [ -n "$(command -v llvm-config19)" ]; then LLVM_CONFIG="llvm-config19"
elif [ -n "$(command -v llvm-config18)" ]; then LLVM_CONFIG="llvm-config18"
elif [ -n "$(command -v llvm-config17)" ]; then LLVM_CONFIG="llvm-config17"
elif [ -n "$(command -v llvm-config14)" ]; then LLVM_CONFIG="llvm-config14"
elif [ -n "$(command -v llvm-config13)" ]; then LLVM_CONFIG="llvm-config13"
elif [ -n "$(command -v llvm-config12)" ]; then LLVM_CONFIG="llvm-config12"
elif [ -n "$(command -v llvm-config11)" ]; then LLVM_CONFIG="llvm-config11"
# fallback
elif [ -n "$(command -v llvm-config)" ]; then LLVM_CONFIG="llvm-config"
else
@@ -58,18 +72,12 @@ LLVM_VERSION_MAJOR="$(echo $LLVM_VERSION | awk -F. '{print $1}')"
LLVM_VERSION_MINOR="$(echo $LLVM_VERSION | awk -F. '{print $2}')"
LLVM_VERSION_PATCH="$(echo $LLVM_VERSION | awk -F. '{print $3}')"
if [ $LLVM_VERSION_MAJOR -lt 11 ] || ([ $LLVM_VERSION_MAJOR -gt 14 ] && [ $LLVM_VERSION_MAJOR -lt 17 ]) || [ $LLVM_VERSION_MAJOR -gt 18 ]; then
error "Invalid LLVM version $LLVM_VERSION: must be 11, 12, 13, 14, 17 or 18"
if [ $LLVM_VERSION_MAJOR -lt 14 ] || ([ $LLVM_VERSION_MAJOR -gt 14 ] && [ $LLVM_VERSION_MAJOR -lt 17 ]) || [ $LLVM_VERSION_MAJOR -gt 21 ]; then
error "Invalid LLVM version $LLVM_VERSION: must be 14, 17, 18, 19, 20, or 21"
fi
case "$OS_NAME" in
Darwin)
if [ "$OS_ARCH" = "arm64" ]; then
if [ $LLVM_VERSION_MAJOR -lt 13 ]; then
error "Invalid LLVM version $LLVM_VERSION: Darwin Arm64 requires LLVM 13, 14, 17 or 18"
fi
fi
darwin_sysroot=
if [ $(which xcrun) ]; then
darwin_sysroot="--sysroot $(xcrun --sdk macosx --show-sdk-path)"
@@ -84,28 +92,28 @@ Darwin)
;;
FreeBSD)
CXXFLAGS="$CXXFLAGS $($LLVM_CONFIG --cxxflags --ldflags)"
LDFLAGS="$LDFLAGS $($LLVM_CONFIG --libs core native --system-libs)"
LDFLAGS="$LDFLAGS -lstdc++ $($LLVM_CONFIG --libs core native --system-libs)"
;;
NetBSD)
CXXFLAGS="$CXXFLAGS $($LLVM_CONFIG --cxxflags --ldflags)"
LDFLAGS="$LDFLAGS $($LLVM_CONFIG --libs core native --system-libs)"
LDFLAGS="$LDFLAGS -lstdc++ $($LLVM_CONFIG --libs core native --system-libs)"
;;
Linux)
CXXFLAGS="$CXXFLAGS $($LLVM_CONFIG --cxxflags --ldflags)"
LDFLAGS="$LDFLAGS -ldl $($LLVM_CONFIG --libs core native --system-libs --libfiles)"
LDFLAGS="$LDFLAGS -lstdc++ -ldl $($LLVM_CONFIG --libs core native --system-libs --libfiles)"
# Copy libLLVM*.so into current directory for linking
# NOTE: This is needed by the Linux release pipeline!
cp $(readlink -f $($LLVM_CONFIG --libfiles)) ./
# cp $(readlink -f $($LLVM_CONFIG --libfiles)) ./
LDFLAGS="$LDFLAGS -Wl,-rpath=\$ORIGIN"
;;
OpenBSD)
CXXFLAGS="$CXXFLAGS $($LLVM_CONFIG --cxxflags --ldflags)"
LDFLAGS="$LDFLAGS -liconv"
CXXFLAGS="$CXXFLAGS -I/usr/local/include $($LLVM_CONFIG --cxxflags --ldflags)"
LDFLAGS="$LDFLAGS -lstdc++ -L/usr/local/lib -liconv"
LDFLAGS="$LDFLAGS $($LLVM_CONFIG --libs core native --system-libs)"
;;
Haiku)
CXXFLAGS="$CXXFLAGS $($LLVM_CONFIG --cxxflags --ldflags) -I/system/develop/headers/private/shared -I/system/develop/headers/private/kernel"
LDFLAGS="$LDFLAGS -liconv"
CXXFLAGS="$CXXFLAGS -D_GNU_SOURCE $($LLVM_CONFIG --cxxflags --ldflags) -I/system/develop/headers/private/shared -I/system/develop/headers/private/kernel"
LDFLAGS="$LDFLAGS -lstdc++ -liconv"
LDFLAGS="$LDFLAGS $($LLVM_CONFIG --libs core native --system-libs)"
;;
*)
@@ -122,7 +130,7 @@ build_odin() {
EXTRAFLAGS="-O3"
;;
release-native)
if [ "$OS_ARCH" = "arm64" ]; then
if [ "$OS_ARCH" = "arm64" ] || [ "$OS_ARCH" = "aarch64" ]; then
# Use preferred flag for Arm (ie arm64 / aarch64 / etc)
EXTRAFLAGS="-O3 -mcpu=native"
else
@@ -144,23 +152,32 @@ build_odin() {
}
run_demo() {
./odin run examples/demo/demo.odin -file -- Hellope World
./odin run examples/demo -vet -strict-style -- Hellope World
}
if [ $# -eq 0 ]; then
build_odin debug
run_demo
: ${PROGRAM:=$0}
printf "\nDebug compiler built. Note: run \"$PROGRAM release\" or \"$PROGRAM release-native\" if you want a faster, release mode compiler.\n"
elif [ $# -eq 1 ]; then
case $1 in
report)
[ ! -f "./odin" ] && build_odin debug
if [ ! -f "./odin" ]; then
build_odin debug
run_demo
fi
./odin report
;;
debug)
build_odin debug
run_demo
;;
*)
build_odin $1
;;
esac
run_demo
else
error "Too many arguments!"
fi
+75
View File
@@ -0,0 +1,75 @@
@echo off
if "%1" == "" (
echo Checking darwin_amd64 - expect vendor:cgltf panic
odin check examples\all -vet -vet-tabs -strict-style -vet-style -warnings-as-errors -disallow-do -target:darwin_amd64
echo Checking darwin_arm64 - expect vendor:cgltf panic
odin check examples\all -vet -vet-tabs -strict-style -vet-style -warnings-as-errors -disallow-do -target:darwin_arm64
echo Checking linux_i386
odin check examples\all -vet -vet-tabs -strict-style -vet-style -warnings-as-errors -disallow-do -target:linux_i386
echo Checking linux_amd64
odin check examples\all -vet -vet-tabs -strict-style -vet-style -warnings-as-errors -disallow-do -target:linux_amd64
echo Checking linux_arm64
odin check examples\all -vet -vet-tabs -strict-style -vet-style -warnings-as-errors -disallow-do -target:linux_arm64
echo Checking linux_arm32
odin check examples\all -vet -vet-tabs -strict-style -vet-style -warnings-as-errors -disallow-do -target:linux_arm32
echo Checking linux_riscv64
odin check examples\all -vet -vet-tabs -strict-style -vet-style -warnings-as-errors -disallow-do -target:linux_riscv64
echo Checking windows_i386
odin check examples\all -vet -vet-tabs -strict-style -vet-style -warnings-as-errors -disallow-do -target:windows_i386
echo Checking windows_amd64
odin check examples\all -vet -vet-tabs -strict-style -vet-style -warnings-as-errors -disallow-do -target:windows_amd64
echo Checking freebsd_amd64
odin check examples\all -vet -vet-tabs -strict-style -vet-style -warnings-as-errors -disallow-do -target:freebsd_amd64
echo Checking freebsd_arm64
odin check examples\all -vet -vet-tabs -strict-style -vet-style -warnings-as-errors -disallow-do -target:freebsd_arm64
echo Checking netbsd_amd64
odin check examples\all -vet -vet-tabs -strict-style -vet-style -warnings-as-errors -disallow-do -target:netbsd_amd64
echo Checking netbsd_arm64
odin check examples\all -vet -vet-tabs -strict-style -vet-style -warnings-as-errors -disallow-do -target:netbsd_arm64
echo Checking openbsd_amd64
odin check examples\all -vet -vet-tabs -strict-style -vet-style -warnings-as-errors -disallow-do -target:openbsd_amd64
)
if "%1" == "freestanding" (
echo Checking freestanding_wasm32
odin check examples\all -vet -vet-tabs -strict-style -vet-style -warnings-as-errors -disallow-do -target:freestanding_wasm32
echo Checking freestanding_wasm64p32
odin check examples\all -vet -vet-tabs -strict-style -vet-style -warnings-as-errors -disallow-do -target:freestanding_wasm64p32
echo Checking freestanding_amd64_sysv
odin check examples\all -vet -vet-tabs -strict-style -vet-style -warnings-as-errors -disallow-do -target:freestanding_amd64_sysv
echo Checking freestanding_amd64_win64
odin check examples\all -vet -vet-tabs -strict-style -vet-style -warnings-as-errors -disallow-do -target:freestanding_amd64_win64
echo Checking freestanding_arm64
odin check examples\all -vet -vet-tabs -strict-style -vet-style -warnings-as-errors -disallow-do -target:freestanding_arm64
echo Checking freestanding_arm32
odin check examples\all -vet -vet-tabs -strict-style -vet-style -warnings-as-errors -disallow-do -target:freestanding_arm32
echo Checking freestanding_riscv64
odin check examples\all -vet -vet-tabs -strict-style -vet-style -warnings-as-errors -disallow-do -target:freestanding_riscv64
)
if "%1" == "rare" (
echo Checking essence_amd64
odin check examples\all -vet -vet-tabs -strict-style -vet-style -warnings-as-errors -disallow-do -target:essence_amd64
echo Checking freebsd_i386
odin check examples\all -vet -vet-tabs -strict-style -vet-style -warnings-as-errors -disallow-do -target:freebsd_i386
echo Checking haiku_amd64
odin check examples\all -vet -vet-tabs -strict-style -vet-style -warnings-as-errors -disallow-do -target:haiku_amd64
)
if "%1" == "wasm" (
echo Checking freestanding_wasm32
odin check examples\all -vet -vet-tabs -strict-style -vet-style -warnings-as-errors -disallow-do -target:freestanding_wasm32
echo Checking freestanding_wasm64p32
odin check examples\all -vet -vet-tabs -strict-style -vet-style -warnings-as-errors -disallow-do -target:freestanding_wasm64p32
echo Checking wasi_wasm64p32
odin check examples\all -vet -vet-tabs -strict-style -vet-style -warnings-as-errors -disallow-do -target:wasi_wasm64p32
echo Checking wasi_wasm32
odin check examples\all -vet -vet-tabs -strict-style -vet-style -warnings-as-errors -disallow-do -target:wasi_wasm32
echo Checking js_wasm32
odin check examples\all -vet -vet-tabs -strict-style -vet-style -warnings-as-errors -disallow-do -target:js_wasm32
echo Checking orca_wasm32
odin check examples\all -vet -vet-tabs -strict-style -vet-style -warnings-as-errors -disallow-do -target:orca_wasm32
echo Checking js_wasm64p32
odin check examples\all -vet -vet-tabs -strict-style -vet-style -warnings-as-errors -disallow-do -target:js_wasm64p32
)
Executable
+78
View File
@@ -0,0 +1,78 @@
#!/bin/sh
case $1 in
freestanding)
echo Checking freestanding_wasm32
odin check examples/all -vet -vet-tabs -strict-style -vet-style -warnings-as-errors -disallow-do -target:freestanding_wasm32
echo Checking freestanding_wasm64p32
odin check examples/all -vet -vet-tabs -strict-style -vet-style -warnings-as-errors -disallow-do -target:freestanding_wasm64p32
echo Checking freestanding_amd64_sysv
odin check examples/all -vet -vet-tabs -strict-style -vet-style -warnings-as-errors -disallow-do -target:freestanding_amd64_sysv
echo Checking freestanding_amd64_win64
odin check examples/all -vet -vet-tabs -strict-style -vet-style -warnings-as-errors -disallow-do -target:freestanding_amd64_win64
echo Checking freestanding_arm64
odin check examples/all -vet -vet-tabs -strict-style -vet-style -warnings-as-errors -disallow-do -target:freestanding_arm64
echo Checking freestanding_arm32
odin check examples/all -vet -vet-tabs -strict-style -vet-style -warnings-as-errors -disallow-do -target:freestanding_arm32
echo Checking freestanding_riscv64
odin check examples/all -vet -vet-tabs -strict-style -vet-style -warnings-as-errors -disallow-do -target:freestanding_riscv64
;;
rare)
echo Checking essence_amd64
odin check examples/all -vet -vet-tabs -strict-style -vet-style -warnings-as-errors -disallow-do -target:essence_amd64
echo Checking freebsd_i386
odin check examples/all -vet -vet-tabs -strict-style -vet-style -warnings-as-errors -disallow-do -target:freebsd_i386
echo Checking haiku_amd64
odin check examples/all -vet -vet-tabs -strict-style -vet-style -warnings-as-errors -disallow-do -target:haiku_amd64
;;
wasm)
echo Checking freestanding_wasm32
odin check examples/all -vet -vet-tabs -strict-style -vet-style -warnings-as-errors -disallow-do -target:freestanding_wasm32
echo Checking freestanding_wasm64p32
odin check examples/all -vet -vet-tabs -strict-style -vet-style -warnings-as-errors -disallow-do -target:freestanding_wasm64p32
echo Checking wasi_wasm64p32
odin check examples/all -vet -vet-tabs -strict-style -vet-style -warnings-as-errors -disallow-do -target:wasi_wasm64p32
echo Checking wasi_wasm32
odin check examples/all -vet -vet-tabs -strict-style -vet-style -warnings-as-errors -disallow-do -target:wasi_wasm32
echo Checking js_wasm32
odin check examples/all -vet -vet-tabs -strict-style -vet-style -warnings-as-errors -disallow-do -target:js_wasm32
echo Checking orca_wasm32
odin check examples/all -vet -vet-tabs -strict-style -vet-style -warnings-as-errors -disallow-do -target:orca_wasm32
echo Checking js_wasm64p32
odin check examples/all -vet -vet-tabs -strict-style -vet-style -warnings-as-errors -disallow-do -target:js_wasm64p32
;;
*)
echo Checking darwin_amd64 - expect vendor:cgltf panic
odin check examples/all -vet -vet-tabs -strict-style -vet-style -warnings-as-errors -disallow-do -target:darwin_amd64
echo Checking darwin_arm64 - expect vendor:cgltf panic
odin check examples/all -vet -vet-tabs -strict-style -vet-style -warnings-as-errors -disallow-do -target:darwin_arm64
echo Checking linux_i386
odin check examples/all -vet -vet-tabs -strict-style -vet-style -warnings-as-errors -disallow-do -target:linux_i386
echo Checking linux_amd64
odin check examples/all -vet -vet-tabs -strict-style -vet-style -warnings-as-errors -disallow-do -target:linux_amd64
echo Checking linux_arm64
odin check examples/all -vet -vet-tabs -strict-style -vet-style -warnings-as-errors -disallow-do -target:linux_arm64
echo Checking linux_arm32
odin check examples/all -vet -vet-tabs -strict-style -vet-style -warnings-as-errors -disallow-do -target:linux_arm32
echo Checking linux_riscv64
odin check examples/all -vet -vet-tabs -strict-style -vet-style -warnings-as-errors -disallow-do -target:linux_riscv64
echo Checking windows_i386
odin check examples/all -vet -vet-tabs -strict-style -vet-style -warnings-as-errors -disallow-do -target:windows_i386
echo Checking windows_amd64
odin check examples/all -vet -vet-tabs -strict-style -vet-style -warnings-as-errors -disallow-do -target:windows_amd64
echo Checking freebsd_amd64
odin check examples/all -vet -vet-tabs -strict-style -vet-style -warnings-as-errors -disallow-do -target:freebsd_amd64
echo Checking freebsd_arm64
odin check examples/all -vet -vet-tabs -strict-style -vet-style -warnings-as-errors -disallow-do -target:freebsd_arm64
echo Checking netbsd_amd64
odin check examples/all -vet -vet-tabs -strict-style -vet-style -warnings-as-errors -disallow-do -target:netbsd_amd64
echo Checking netbsd_arm64
odin check examples/all -vet -vet-tabs -strict-style -vet-style -warnings-as-errors -disallow-do -target:netbsd_arm64
echo Checking openbsd_amd64
odin check examples/all -vet -vet-tabs -strict-style -vet-style -warnings-as-errors -disallow-do -target:openbsd_amd64
;;
esac
+19
View File
@@ -0,0 +1,19 @@
#!/usr/bin/env sh
# Intended for use in Alpine containers, see the "nightly" Github action for a list of dependencies
CXX="clang++-20"
LLVM_CONFIG="llvm-config-20"
DISABLED_WARNINGS="-Wno-switch -Wno-macro-redefined -Wno-unused-value"
CPPFLAGS="-DODIN_VERSION_RAW=\"dev-$(date +"%Y-%m")\""
CXXFLAGS="-std=c++14 $($LLVM_CONFIG --cxxflags --ldflags)"
LDFLAGS="-static -lm -lzstd -lz -lffi -pthread -ldl -fuse-ld=mold"
LDFLAGS="$LDFLAGS $($LLVM_CONFIG --link-static --ldflags --libs --system-libs --libfiles)"
LDFLAGS="$LDFLAGS -Wl,-rpath=\$ORIGIN"
EXTRAFLAGS="-DNIGHTLY -O3"
set -x
$CXX src/main.cpp src/libtommath.cpp $DISABLED_WARNINGS $CPPFLAGS $CXXFLAGS $EXTRAFLAGS $LDFLAGS -o odin
-50
View File
@@ -1,50 +0,0 @@
import subprocess
import sys
import json
import datetime
import urllib.parse
import sys
def main():
files_by_date = {}
bucket = sys.argv[1]
files_lines = execute_cli(f"b2 ls --long b2://{bucket}/nightly/").split("\n")
for x in files_lines:
parts = x.split(" ", 1)
if parts[0]:
json_str = execute_cli(f"b2 file info {parts[0]}")
data = json.loads(json_str)
name = remove_prefix(data['fileName'], "nightly/")
url = f"https://f001.backblazeb2.com/file/{bucket}/nightly/{urllib.parse.quote_plus(name)}"
sha1 = data['contentSha1']
size = int(data['size'])
ts = int(data['fileInfo']['src_last_modified_millis'])
date = datetime.datetime.fromtimestamp(ts/1000).strftime('%Y-%m-%d')
if date not in files_by_date.keys():
files_by_date[date] = []
files_by_date[date].append({
'name': name,
'url': url,
'sha1': sha1,
'sizeInBytes': size,
})
now = datetime.datetime.utcnow().isoformat()
print(json.dumps({
'last_updated' : now,
'files': files_by_date
}, sort_keys=True, indent=4))
def remove_prefix(text, prefix):
return text[text.startswith(prefix) and len(prefix):]
def execute_cli(command):
sb = subprocess.Popen(command, shell=True, stdout=subprocess.PIPE)
return sb.stdout.read().decode("utf-8");
if __name__ == '__main__':
sys.exit(main())
-33
View File
@@ -1,33 +0,0 @@
import subprocess
import sys
import json
import datetime
import urllib.parse
import sys
def main():
files_by_date = {}
bucket = sys.argv[1]
days_to_keep = int(sys.argv[2])
print(f"Looking for binaries to delete older than {days_to_keep} days")
files_lines = execute_cli(f"b2 ls --long --versions b2://{bucket}/nightly/").split("\n")
for x in files_lines:
parts = [y for y in x.split(' ') if y]
if parts and parts[0]:
date = datetime.datetime.strptime(parts[2], '%Y-%m-%d').replace(hour=0, minute=0, second=0, microsecond=0)
now = datetime.datetime.utcnow().replace(hour=0, minute=0, second=0, microsecond=0)
delta = now - date
if delta.days > days_to_keep:
print(f'Deleting {parts[5]}')
execute_cli(f'b2 rm {parts[0]}')
def execute_cli(command):
sb = subprocess.Popen(command, shell=True, stdout=subprocess.PIPE)
return sb.stdout.read().decode("utf-8");
if __name__ == '__main__':
sys.exit(main())
+145
View File
@@ -0,0 +1,145 @@
import os
import sys
from zipfile import ZipFile, ZIP_DEFLATED
from b2sdk.v2 import InMemoryAccountInfo, B2Api
from datetime import datetime, timezone
import json
UPLOAD_FOLDER = "nightly/"
info = InMemoryAccountInfo()
b2_api = B2Api(info)
application_key_id = os.environ['APPID']
application_key = os.environ['APPKEY']
bucket_name = os.environ['BUCKET']
days_to_keep = os.environ['DAYS_TO_KEEP']
def auth() -> bool:
try:
realm = b2_api.account_info.get_realm()
return True # Already authenticated
except:
pass # Not yet authenticated
err = b2_api.authorize_account("production", application_key_id, application_key)
return err is None
def get_bucket():
if not auth(): sys.exit(1)
return b2_api.get_bucket_by_name(bucket_name)
def remove_prefix(text: str, prefix: str) -> str:
return text[text.startswith(prefix) and len(prefix):]
def create_and_upload_artifact_zip(platform: str, artifact: str) -> int:
now = datetime.now(timezone.utc).replace(hour=0, minute=0, second=0, microsecond=0)
source_archive: str
destination_name = f'odin-{platform}-nightly+{now.strftime("%Y-%m-%d")}'
if platform.startswith("linux") or platform.startswith("macos"):
destination_name += ".tar.gz"
source_archive = artifact
else:
destination_name += ".zip"
source_archive = destination_name
print(f"Creating archive {destination_name} from {artifact} and uploading to {bucket_name}")
with ZipFile(source_archive, mode='w', compression=ZIP_DEFLATED, compresslevel=9) as z:
for root, directory, filenames in os.walk(artifact):
for file in filenames:
file_path = os.path.join(root, file)
zip_path = os.path.join("dist", os.path.relpath(file_path, artifact))
z.write(file_path, zip_path)
if not os.path.exists(source_archive):
print(f"Error: archive {source_archive} not found.")
return 1
print("Uploading {} to {}".format(source_archive, UPLOAD_FOLDER + destination_name))
bucket = get_bucket()
res = bucket.upload_local_file(
source_archive, # Local file to upload
"nightly/" + destination_name, # B2 destination path
)
return 0
def prune_artifacts():
print(f"Looking for binaries to delete older than {days_to_keep} days")
bucket = get_bucket()
for file, _ in bucket.ls(UPLOAD_FOLDER, latest_only=False):
# Timestamp is in milliseconds
date = datetime.fromtimestamp(file.upload_timestamp / 1_000.0, tz=timezone.utc).replace(hour=0, minute=0, second=0, microsecond=0)
now = datetime.now(timezone.utc).replace(hour=0, minute=0, second=0, microsecond=0)
delta = now - date
if delta.days > int(days_to_keep):
print("Deleting {}".format(file.file_name))
file.delete()
return 0
def update_nightly_json():
print(f"Updating nightly.json with files {days_to_keep} days or newer")
files_by_date = {}
bucket = get_bucket()
for file, _ in bucket.ls(UPLOAD_FOLDER, latest_only=True):
# Timestamp is in milliseconds
date = datetime.fromtimestamp(file.upload_timestamp / 1_000.0).replace(hour=0, minute=0, second=0, microsecond=0).strftime('%Y-%m-%d')
name = remove_prefix(file.file_name, UPLOAD_FOLDER)
sha1 = file.content_sha1
size = file.size
url = bucket.get_download_url(file.file_name)
if date not in files_by_date.keys():
files_by_date[date] = []
files_by_date[date].append({
'name': name,
'url': url,
'sha1': sha1,
'sizeInBytes': size,
})
now = datetime.now(timezone.utc).isoformat()
nightly = json.dumps({
'last_updated' : now,
'files': files_by_date
}, sort_keys=True, indent=4, ensure_ascii=False).encode('utf-8')
res = bucket.upload_bytes(
nightly, # JSON bytes
"nightly.json", # B2 destination path
)
return 0
if __name__ == "__main__":
if len(sys.argv) == 1:
print("Usage: {} <verb> [arguments]".format(sys.argv[0]))
print("\tartifact <platform prefix> <artifact path>\n\t\tCreates and uploads a platform artifact zip.")
print("\tprune\n\t\tDeletes old artifacts from bucket")
print("\tjson\n\t\tUpdate and upload nightly.json")
sys.exit(1)
else:
command = sys.argv[1].lower()
if command == "artifact":
if len(sys.argv) != 4:
print("Usage: {} artifact <platform prefix> <artifact path>".format(sys.argv[0]))
print("Error: Expected artifact command to be given platform prefix and artifact path.\n")
sys.exit(1)
res = create_and_upload_artifact_zip(sys.argv[2], sys.argv[3])
sys.exit(res)
elif command == "prune":
res = prune_artifacts()
sys.exit(res)
elif command == "json":
res = update_nightly_json()
sys.exit(res)
+8
View File
@@ -0,0 +1,8 @@
#!/usr/bin/env sh
find "$1" -type f \(\
-iname "*.exe" \
-o -iname "*.dll" \
-o -iname "*.lib" \
-o -iname "*.pdb" \
\) -delete
-25
View File
@@ -1,25 +0,0 @@
#!/bin/bash
set -e
bucket=$1
platform=$2
artifact=$3
now=$(date +'%Y-%m-%d')
filename="odin-$platform-nightly+$now.zip"
echo "Creating archive $filename from $artifact and uploading to $bucket"
# If this is already zipped up (done before artifact upload to keep permissions in tact), just move it.
if [ "${artifact: -4}" == ".zip" ]
then
echo "Artifact already a zip"
mkdir -p "output"
mv "$artifact" "output/$filename"
else
echo "Artifact needs to be zipped"
7z a -bd "output/$filename" -r "$artifact"
fi
b2 file upload "$bucket" "output/$filename" "nightly/$filename"
+6
View File
@@ -0,0 +1,6 @@
comment: false
coverage:
status:
project:
default:
threshold: 1%
+661
View File
@@ -0,0 +1,661 @@
/*
AST_KINDS swap content
These are not to be used directly. They are parsed by gen_src.cpp
Everything within the Ast_Kinds region has a specific format pair:
1. char const* strings
2. struct or typedef definition.
The string descriptions are put into the Ast_strings lookup table.
The actual struct definitions used will have the Ast prefix-namespace appended to them.
*/
char const* desc_Ident = "identifier";
struct Ident {
Token token;
Entity *entity;
u32 hash;
};
char const* desc_Implicit = "implicit";
typedef Token Implicit;
char const* desc_Uninit = "uninitialized value";
typedef Token Uninit;
char const* desc_BasicLit = "basic literal";
struct BasicLit {
Token token;
};
char const* desc_BasicDirective = "basic directive";
struct BasicDirective {
Token token;
Token name;
};
char const* desc_Ellipsis = "ellipsis";
struct Ellipsis {
Token token;
Ast *expr;
};
char const* desc_ProcGroup = "procedure group";
struct ProcGroup {
Token token;
Token open;
Token close;
Slice<Ast *> args;
};
char const* desc_ProcLit = "procedure literal";
struct ProcLit {
Ast *type;
Ast *body;
u64 tags;
ProcInlining inlining;
Token where_token;
Slice<Ast *> where_clauses;
DeclInfo *decl;
};
char const* desc_CompountLit = "compound literal";
struct CompoundLit {
Ast *type;
Slice<Ast *> elems;
Token open, close;
i64 max_count;
Ast *tag;
};
#pragma region Expressions
char const* desc_ExprBegin = "";
typedef bool _ExprBegin;
char const* desc_BadExpr = "bad expression";
struct BadExpr {
Token begin, end;
};
char const* desc_TagExpr = "tag expression";
struct TagExpr {
Token token, name;
Ast *expr;
};
char const* desc_UnaryExpr = "unary expression";
struct UnaryExpr {
Token op;
Ast *expr;
};
char const* desc_BinaryExpr = "binary expression";
struct BinaryExpr {
Token op;
Ast *left, *right;
};
char const* desc_ParenExpr = "parentheses expression";
struct ParenExpr {
Ast *expr;
Token open, close;
};
char const* desc_SelectorExpr = "selector expression";
struct SelectorExpr {
Token token;
Ast *expr, *selector;
u8 swizzle_count; /*maximum of 4 components, if set, count >= 2*/
u8 swizzle_indices; /*2 bits per component*/
bool is_bit_field;
};
char const* desc_ImplicitSelectorExpr = "implicit selector expression";
struct ImplicitSelectorExpr {
Token token;
Ast *selector;
};
char const* desc_SelectorCallExpr = "selector call expression";
struct SelectorCallExpr {
Token token;
Ast *expr, *call;
bool modified_call;
};
char const* desc_IndentExpr = "index expression";
struct IndexExpr {
Ast *expr, *index;
Token open, close;
};
char const* desc_DerefExpr = "dereference expression";
struct DerefExpr {
Ast *expr;
Token op;
};
char const* desc_SliceExpr = "slice expression";
struct SliceExpr {
Ast *expr;
Token open, close;
Token interval;
Ast *low, *high;
};
char const* desc_CallExpr = "call expression";
struct CallExpr {
Ast *proc;
Slice<Ast *> args;
Token open;
Token close;
Token ellipsis;
ProcInlining inlining;
bool optional_ok_one;
bool was_selector;
AstSplitArgs *split_args;
Entity *entity_procedure_of;
};
char const* desc_FieldValue = "field value";
struct FieldValue {
Token eq;
Ast *field, *value;
};
char const* desc_EnumFieldValue = "enum field value";
struct EnumFieldValue {
Ast *name;
Ast *value;
CommentGroup *docs;
CommentGroup *comment;
};
char const* desc_TernaryIfExpr = "ternary if expression";
struct TernaryIfExpr {
Ast *x, *cond, *y;
};
char const* desc_TernaryWhenExpr = "ternary when expression";
struct TernaryWhenExpr {
Ast *x, *cond, *y;
};
char const* desc_OrElseExpr = "or_else expression";
struct OrElseExpr {
Ast *x;
Token token;
Ast *y;
};
char const* desc_OrReturnExpr = "or_return expression";
struct OrReturnExpr {
Ast *expr;
Token token;
};
char const* desc_OrBranchExpr = "or branch expression";
struct OrBranchExpr {
Ast *expr;
Token token;
Ast *label;
};
char const* desc_TypeAssertion = "type assertion";
struct TypeAssertion {
Ast *expr;
Token dot;
Ast *type;
Type *type_hint;
bool ignores[2];
};
char const* desc_TypeCAst = "type cAst";
struct TypeCast {
Token token;
Ast *type, *expr;
};
char const* desc_AutoCAst = "auto_cAst";
struct AutoCast {
Token token;
Ast *expr;
};
char const* desc_InlineAsmExpr = "inline asm expression";
struct InlineAsmExpr {
Token token;
Token open, close;
Slice<Ast *> param_types;
Ast *return_type;
Ast *asm_string;
Ast *constraints_string;
bool has_side_effects;
bool is_align_stack;
InlineAsmDialectKind dialect;
};
char const* desc_MatrixIndexExpr = "matrix index expression";
struct MatrixIndexExpr {
Ast *expr, *row_index, *column_index;
Token open, close;
};
char const* desc__ExprEnd = "";
typedef bool _ExprEnd;
#pragma endregion Expressions
#pragma region Statements
char const* desc__StmtBegin = "";
typedef bool _StmtBegin;
char const* desc_BadStmt = "bad statement";
struct BadStmt {
Token begin, end;
};
char const* desc_EmptyStmt = "empty statement";
struct EmptyStmt {
Token token;
};
char const* desc_ExprStmt = "expression statement";
struct ExprStmt {
Ast* expr;
};
char const* desc_AssignStmt = "assign statement";
struct AssignStmt {
Token op;
Slice<Ast *> lhs, rhs;
};
#pragma region Complex Statements
char const* desc__ComplexStmtBegin = "";
typedef bool _ComplexStmtBegin;
char const* desc_BlockStmt = "block statement";
struct BlockStmt {
Scope *scope;
Slice<Ast *> stmts;
Ast *label;
Token open, close;
};
char const* desc_IfStmt = "if statement";
struct IfStmt {
Scope *scope;
Token token;
Ast *label;
Ast *init;
Ast *cond;
Ast *body;
Ast *else_stmt;
};
char const* desc_WhenStmt = "when statement";
struct WhenStmt {
Token token;
Ast *cond;
Ast *body;
Ast *else_stmt;
bool is_cond_determined;
bool determined_cond;
};
char const* desc_ReturnStmt = "return statement";
struct ReturnStmt {
Token token;
Slice<Ast *> results;
};
char const* desc_ForStmt = "for statement";
struct ForStmt {
Scope *scope;
Token token;
Ast *label;
Ast *init;
Ast *cond;
Ast *post;
Ast *body;
};
char const* desc_RangeStmt = "range statement";
struct RangeStmt {
Scope *scope;
Token token;
Ast *label;
Slice<Ast *> vals;
Token in_token;
Ast *expr;
Ast *body;
bool reverse;
};
char const* desc_UnrollRangeStmt = "unroll range statement";
struct UnrollRangeStmt {
Scope *scope;
Token unroll_token;
Slice<Ast *> args;
Token for_token;
Ast *val0;
Ast *val1;
Token in_token;
Ast *expr;
Ast *body;
};
char const* desc_CaseClause = "case clause";
struct CaseClause {
Scope *scope;
Token token;
Slice<Ast *> list;
Slice<Ast *> stmts;
Entity *implicit_entity;
};
char const* desc_SwitchStmt = "switch statement";
struct SwitchStmt {
Scope *scope;
Token token;
Ast *label;
Ast *init;
Ast *tag;
Ast *body;
bool partial;
};
char const* desc_TypeSwitchStmt = "type switch statement";
struct TypeSwitchStmt {
Scope *scope;
Token token;
Ast *label;
Ast *tag;
Ast *body;
bool partial;
};
char const* desc_DeferStmt = "defer statement";
struct DeferStmt {
Token token;
Ast* stmt;
};
char const* desc_BranchStmt = "branch statement";
struct BranchStmt {
Token token;
Ast* label;
};
char const* desc_UsingStmt = "using statement";
struct UsingStmt {
Token token;
Slice<Ast *> list;
};
char const* desc__ComplexStmtEnd = "";
typedef bool _ComplexStmtEnd;
#pragma endregion Complex Statements
char const* desc__StmtEnd = "";
typedef bool _StmtEnd;
#pragma endregion Statements
#pragma region Declarations
char const* desc__DeclBegin = "";
typedef bool _DeclBegin;
char const* desc_BadDecl = "bad declaration";
struct BadDecl {
Token begin, end;
};
char const* desc_ForeignBlockDecl = "foreign block declaration";
struct ForeignBlockDecl {
Token token;
Ast *foreign_library;
Ast *body;
Array<Ast *> attributes;
CommentGroup *docs;
};
char const* desc_Label = "label";
struct Label {
Token token;
Ast *name;
};
char const* desc_ValueDecl = "value declaration";
struct ValueDecl {
Slice<Ast *> names;
Ast *type;
Slice<Ast *> values;
Array<Ast *> attributes;
CommentGroup *docs;
CommentGroup *comment;
bool is_using;
bool is_mutable;
};
char const* desc_PackageDecl = "package declaration";
struct PackageDecl {
Token token;
Token name;
CommentGroup *docs;
CommentGroup *comment;
};
char const* desc_ImportDecl = "import declaration";
struct ImportDecl {
AstPackage *package;
Token token;
Token relpath;
String fullpath;
Token import_name;
Array<Ast *> attributes;
CommentGroup *docs;
CommentGroup *comment;
};
char const* desc_ForeignImportDecl = "foreign import declaration";
struct ForeignImportDecl {
Token token;
Slice<Ast *> filepaths;
bool multiple_filepaths;
Token library_name;
String collection_name;
Slice<String> fullpaths;
Array<Ast *> attributes;
CommentGroup *docs;
CommentGroup *comment;
};
char const* desc__DeclEnd = "";
typedef bool _DeclEnd;
#pragma endregion Declarations
char const* desc_Attribute = "attribute";
struct Attribute {
Token token;
Slice<Ast *> elems;
Token open, close;
};
char const* desc_Field = "field";
struct Field {
Slice<Ast *> names;
Ast *type;
Ast *default_value;
Token tag;
u32 flags;
CommentGroup *docs;
CommentGroup *comment;
};
char const* desc_BitFieldField = "bit field field";
struct BitFieldField {
Ast *name;
Ast *type;
Ast *bit_size;
Token tag;
CommentGroup *docs;
CommentGroup *comment;
};
char const* desc_FieldList = "field list";
struct FieldList {
Token token;
Slice<Ast *> list;
};
#pragma region Types
char const* desc__TypeBegin = "";
typedef bool _TypeBegin;
char const* desc_TypeidType = "typeid";
struct TypeidType
{
Token token;
Ast *specialization;
};
char const* desc_HelperType = "helper type";
struct HelperType {
Token token;
Ast *type;
};
char const* desc_DistinctType = "distinct type";
struct DistinctType {
Token token;
Ast *type;
};
char const* desc_PolyType = "polymorphic type";
struct PolyType {
Token token;
Ast *type;
Ast *specialization;
};
char const* desc_ProcType = "procedure type";
struct ProcType {
Scope *scope;
Token token;
Ast *params;
Ast *results;
u64 tags;
ProcCallingConvention calling_convention;
bool generic;
bool diverging;
};
char const* desc_PointerType = "pointer type";
struct PointerType {
Token token;
Ast *type;
Ast *tag;
};
char const* desc_RelativeType = "relative type";
struct RelativeType {
Ast *tag;
Ast *type;
};
char const* desc_MultiPointerType = "multi pointer type";
struct MultiPointerType {
Token token;
Ast *type;
};
char const* desc_ArrayType = "array type";
struct ArrayType {
Token token;
Ast *count;
Ast *elem;
Ast *tag;
};
char const* desc_DynamicType = "dynamic array type";
struct DynamicArrayType {
Token token;
Ast *elem;
Ast *tag;
};
char const* desc_StructType = "struct type";
struct StructType {
Scope *scope;
Token token;
Slice<Ast *> fields;
isize field_count;
Ast *polymorphic_params;
Ast *align;
Ast *min_field_align;
Ast *max_field_align;
Token where_token;
Slice<Ast *> where_clauses;
bool is_packed;
bool is_raw_union;
bool is_no_copy;
};
char const* desc_UnionType = "union type";
struct UnionType {
Scope *scope;
Token token;
Slice<Ast *> variants;
Ast *polymorphic_params;
Ast *align;
UnionTypeKind kind;
Token where_token;
Slice<Ast *> where_clauses;
};
char const* desc_EnumType = "enum type";
struct EnumType {
Scope *scope;
Token token;
Ast *base_type;
Slice<Ast *> fields; /* FieldValue */
bool is_using;
};
char const* dec_BitSetType = "bitset type";
struct BitSetType {
Token token;
Ast *elem;
Ast *underlying;
};
char const* desc_BitfieldType = "bitfield type";
struct BitFieldType {
Scope *scope;
Token token;
Ast *backing_type;
Token open;
Slice<Ast *> fields; /* BitFieldField */
Token close;
};
char const* desc_MapType = "map type";
struct MapType {
Token token;
Ast *count;
Ast *key;
Ast *value;
};
char const* desc_MatrixType = "matrix type";
struct MatrixType {
Token token;
Ast *row_count;
Ast *column_count;
Ast *elem;
bool is_row_major;
};
char const* desc__TypeEnd = "";
typedef bool _TypeEnd;
#pragma endregion Types
+555
View File
@@ -0,0 +1,555 @@
#if __clang__
#pragma clang diagnostic ignored "-Wswitch"
#endif
#define GEN_DEFINE_LIBRARY_CODE_CONSTANTS
#define GEN_ENFORCE_STRING_CODE_TYPES
#define GEN_EXPOSE_BACKEND
#define GEN_IMPLEMENTATION
// #define GEN_DONT_USE_FATAL
#include "gencpp/gen.hpp"
using namespace gen;
#ifdef GEN_SYSTEM_WINDOWS
#include <process.h>
// #include <Windows.h>
#endif
#pragma region Directories
// Program assumes its working directory is the src directory
#define path_root ""
#define path_codegen path_root "codegen/"
#define path_src path_root "src/"
#pragma endregion Directories
inline
void git_restore_file( char const* path )
{
#define git_restore_cmd "git restore "
StrBuilder command = StrBuilder::make( _ctx->Allocator_Temp, git_restore_cmd );
command.append( path );
log_fmt("Running git restore on: %s", path);
system(command);
#undef git_restore_cmd
Sleep(5);
}
inline
void format_file( char const* path )
{
// Need to execute clang format on the generated file to get it to match the original.
#define clang_format "clang-format "
#define cf_format_inplace "-i "
#define cf_style "-style=file:" "./scripts/.clang-format "
#define cf_verbose "-verbose "
StrBuilder command = StrBuilder::make( _ctx->Allocator_Temp, clang_format );
command.append( cf_format_inplace );
command.append( cf_style );
command.append( cf_verbose );
command.append( path );
log_fmt("\tRunning clang-format on file: %s\n", path);
system( command );
log_fmt("\tclang-format finished reformatting.\n");
#undef cf_cmd
#undef cf_format_inplace
#undef cf_style
#undef cf_verbse
}
struct Odin_AstKind {
StrCached desc;
Code def;
};
Array<Odin_AstKind> get_odin_ast_kinds()
{
local_persist Array<Odin_AstKind> kinds = Array<Odin_AstKind>::init_reserve(_ctx->Allocator_Temp, kilobytes(64));
{
local_persist s32 done_once = 0;
if (done_once)
return kinds;
++ done_once;
}
CodeTypename t_char_const_ptr = parse_type(code(char const*));
CodeBody ast_kinds_header = parse_file( path_codegen "ast_kinds.hpp" );
for ( Code code = ast_kinds_header.begin(); code != ast_kinds_header.end(); ++ code )
{
switch (code->Type)
{
case CT_Comment:
case CT_Preprocess_Pragma:
// Ignore
continue;
case CT_Variable:
{
Odin_AstKind entry {};
CodeVar var = cast(CodeVar, code);
if ( ! var->ValueType.is_equal( t_char_const_ptr ) )
{
log_failure("Expected all globally defined variables to be char cons* type");
return kinds;
}
if ( ! var->Value || ! var->Value->Content )
{
log_failure("Expected all globally defined variable to have a string assigned to it");
return kinds;
}
// Grab the description
entry.desc = var->Value->Content;
++ code;
// Grab the definition
if ( code->Type != CT_Struct && code->Type != CT_Typedef )
{
log_failure("Expected a struct or typedef for the entry definition");
return kinds;
}
entry.def = code;
kinds.append(entry);
}
continue;
case CT_Struct:
log_failure("Expected a description definition as char const* first");
return kinds;
break;
}
}
return kinds;
}
Array<Code> get_odin_type_kinds()
{
local_persist Array<Code> types = Array<Code>::init_reserve(_ctx->Allocator_Temp, kilobytes(64));
{
local_persist s32 done_once = 0;
if (done_once)
return types;
++ done_once;
}
CodeBody ast_types_header = parse_file( path_codegen "type_kinds.hpp" );
for ( Code code = ast_types_header.begin(); code != ast_types_header.end(); ++ code ) switch (code->Type)
{
case CT_Comment:
case CT_Preprocess_Pragma:
// Ignore
continue;
case CT_Typedef:
case CT_Struct:
{
types.append(code);
}
}
return types;
}
int gen_main()
{
Context ctx {};
gen::init(& ctx);
log_fmt("Generating code for Odin's src\n");
register_macros( args(
(Macro {txt("GB_STATIC_ASSERT"), MT_Statement, MF_Functional }),
(Macro {txt("TOKEN_KIND"), MT_Expression, MF_Functional }),
(Macro {txt("TOKEN_KINDS"), MT_Statement, MF_Null }),
(Macro {txt("PARSER_MAX_FIX_COUNT"), MT_Expression, MF_Null }),
(Macro {txt("AST_KINDS"), MT_Statement, MF_Null }),
(Macro {txt("AST_KIND"), MT_Expression, MF_Functional }),
(Macro {txt("ast_node"), MT_Expression, MF_Functional }),
(Macro {txt("case_ast_node"), MT_Expression, MF_Functional }),
(Macro {txt("case_end"), MT_Expression, MF_Null }),
(Macro {txt("TYPE_KIND"), MT_Expression, MF_Functional }),
(Macro {txt("TYPE_KINDS"), MT_Statement, MF_Null }),
(Macro {txt("FAILURE_SIZE"), MT_Expression, MF_Null }),
(Macro {txt("FAILURE_ALIGNMENT"), MT_Expression, MF_Null }),
(Macro {txt("_ARRAY_FIELD_CASE_IF"), MT_Statement, MF_Functional }),
(Macro {txt("_ARRAY_FIELD_CASE"), MT_Expression, MF_Functional })
));
// Remove TOKEN_KINDS usage in tokenizer.cpp
// Note this doesn't account for an already swapped file. Make sure to discard changes or shut this path off if already generated.
if (1)
{
CSV_Object csv_nodes;
{
char scratch_mem[kilobytes(32)];
Arena scratch = Arena::init_from_memory( scratch_mem, sizeof(scratch_mem) );
file_read_contents( scratch, file_zero_terminate, path_codegen "token_kinds.csv" );
csv_parse( &csv_nodes, scratch_mem, ctx.Allocator_Temp, false );
}
Array<ADT_Node> enum_strs = csv_nodes.nodes[0].nodes;
Array<ADT_Node> str_strs = csv_nodes.nodes[1].nodes;
StrBuilder enum_entries = StrBuilder::make_reserve( ctx.Allocator_Temp, kilobytes(32) );
StrBuilder to_str_entries = StrBuilder::make_reserve( ctx.Allocator_Temp, kilobytes(32) );
to_str_entries.append(txt("{"));
for (usize idx = 0; idx < enum_strs.num(); idx++)
{
char const* enum_str = enum_strs[idx].string;
Str entry_to_str = to_str_from_c_str(str_strs [idx].string);
#pragma push_macro("cast")
#undef cast
enum_entries.append_fmt( "Token_%s,\n", enum_str );
to_str_entries.append( token_fmt( "str", (Str)entry_to_str, stringize(
{ cast(u8 *) "<str>", gb_size_of("<str>") -1 },\n
)));
#pragma pop_macro("cast")
}
to_str_entries.append(txt("}"));
char const* path_tokenizer = path_src "tokenizer.cpp";
git_restore_file( path_tokenizer );
CodeBody src_tokenizer_cpp = parse_file( path_src "tokenizer.cpp" );
CodeBody body = def_body( CT_Global_Body );
body.append( def_comment(txt("NOTICE(github: Ed94): This is a generated variant of tokenizer.cpp using <repo_root>/codegen/gen_src.cpp")));
body.append(fmt_newline);
for (Code code = src_tokenizer_cpp.begin(); code != src_tokenizer_cpp.end(); ++ code) switch (code->Type)
{
case CT_Preprocess_Define:
if ( code->Name.starts_with( txt("TOKEN_KINDS"))) {
// Skip, we don't want it.
continue;
}
continue;
case CT_Enum:
{
if ( code->Name.starts_with(txt("TokenKind")))
{
CodeEnum enum_code = cast(CodeEnum, code);
enum_code->Body = untyped_str(enum_entries);
}
body.append(code);
}
continue;
case CT_Variable:
if ( code->Name.starts_with(txt("token_strings")))
{
CodeVar var = cast(CodeVar, code);
var->Value = untyped_str(to_str_entries);
}
body.append(code);
continue;
default:
body.append(code);
continue;
}
Builder src = Builder::open( path_src "tokenizer.cpp" );
src.print(body);
src.write();
format_file( path_src "tokenizer.cpp" );
}
// Remove AST_KINDS macro usage in parser.hpp
// Note this doesn't account for an already swapped file. Make sure to discard changes or shut this path off if already generated.
if (1)
{
char const* path_parser = path_src "parser.hpp";
git_restore_file( path_parser );
CodeBody src_parser_header = parse_file( path_src "parser.hpp" );
CodeBody body = def_body( CT_Global_Body );
body.append( def_comment(txt("NOTICE(github: Ed94): This is a generated variant of parser.hpp using <repo_root>/codegen/gen_src.cpp")));
body.append(fmt_newline);
Array<Odin_AstKind> ast_kinds = get_odin_ast_kinds();
for (Code code = src_parser_header.begin(); code != src_parser_header.end(); ++ code)
{
switch (code->Type)
{
case CT_Preprocess_Define:
if ( code->Name.starts_with( txt("AST_KINDS"))) {
// Skip, we don't want it.
continue;
}
if ( code->Name.starts_with( txt("AST_KIND"))) {
// Skip the next 3 definitions
++ code;
++ code;
continue;
}
body.append(code);
continue;
case CT_Untyped:
if (code->Content.starts_with(txt("AST_KINDS")))
continue;
body.append(code);
continue;
case CT_Enum:
{
if (code->Name.starts_with( txt("AstKind")))
{
// Swap with generated variant
CodeBody swap_body = def_body( CT_Enum_Body );
{
swap_body.append( code_str(Ast_Invalid,));
for (Odin_AstKind& kind : ast_kinds)
swap_body.append( untyped_str( StrBuilder::fmt_buf(ctx.Allocator_Temp, "Ast_%S,", kind.def->Name )));
swap_body.append( code_str(Ast_COUNT));
}
CodeEnum swapped_enum = cast(CodeEnum, code).duplicate();
swapped_enum->Body = swap_body;
body.append(swapped_enum);
}
else
body.append(code);
}
continue;
case CT_Variable:
{
if (code->Name.starts_with(txt("ast_strings")))
{
// Swap with generated table
StrBuilder generated_table = StrBuilder::make_reserve(ctx.Allocator_Temp, kilobytes(32));
{
#pragma push_macro("cast")
#undef cast
for (Odin_AstKind& kind : ast_kinds)
generated_table.append(token_fmt("desc", (Str)kind.desc, stringize(
{ cast(u8 *) <desc>, gb_size_of(<desc>) -1 },
)));
#pragma pop_macro("cast")
}
CodeVar swapped_table = cast(CodeVar, code).duplicate();
#pragma push_macro("cast")
#undef cast
swapped_table->Value = code_fmt( "kinds", (Str)generated_table, stringize(
{
{ cast(u8 *)"invalid node", gb_size_of("invalid node")},\n
<kinds>
}));
#pragma pop_macro("cast")
body.append(swapped_table);
body.append(fmt_newline);
// Right after is where the struct definitions were defined, we'll insert them here
body.append(def_pragma(txt("region AST_KINDS")));
body.append(fmt_newline);
for (Odin_AstKind& kind : ast_kinds)
{
Code def = kind.def.duplicate();
def->Name = cache_str( StrBuilder::fmt_buf(ctx.Allocator_Temp, "Ast%S", kind.def->Name));
body.append( def );
body.append(fmt_newline);
}
body.append(def_pragma(txt("endregion AST_KINDS")));
continue;
}
if (code->Name.starts_with(txt("ast_variant_sizes")))
{
// Swap with generated table
StrBuilder generated_table = StrBuilder::make_reserve(ctx.Allocator_Temp, kilobytes(32));
{
for (Odin_AstKind& kind : ast_kinds)
generated_table.append(token_fmt( "name", (Str)kind.def->Name, stringize(
gb_size_of(Ast<name>),\n
)));
}
CodeVar swapped_table = cast(CodeVar, code).duplicate();
swapped_table->Value = code_fmt( "kinds", (Str)generated_table, stringize(
{
0,\n
<kinds>
}));
body.append(swapped_table);
continue;
}
body.append(code);
}
continue;
case CT_Struct:
{
CodeStruct code_struct = cast(CodeStruct, code);
if (code->Name.starts_with(txt("Ast")))
for (Code ast_code : code_struct->Body) switch (ast_code->Type)
{
case CT_Union:
{
// Swap out the union's contents with the generated member definitions
CodeBody body_swap = def_body(CT_Union_Body);
for (Odin_AstKind kind : ast_kinds)
body_swap.append( parse_variable( token_fmt( "name", (Str)kind.def->Name, stringize(
Ast<name> <name>;
))));
ast_code->Body = body_swap;
}
break;
default:
continue;
}
body.append(code);
}
continue;
default:
body.append(code);
continue;
}
}
Builder header = Builder::open( path_src "parser.hpp" );
header.print(body);
header.write();
format_file( path_src "parser.hpp" );
}
// Remove TYPE_KINDS usage in types.cpp
// Note this doesn't account for an already swapped file. Make sure to discard changes or shut this path off if already generated.
if (1)
{
char const* path_types = path_src "types.cpp";
git_restore_file( path_types );
CodeBody src_types_cpp = parse_file( path_src "types.cpp" );
CodeBody body = def_body( CT_Global_Body );
body.append( def_comment(txt("NOTICE(github: Ed94): This is a generated variant of types.cpp using <repo_root>/codegen/gen_src.cpp")));
body.append(fmt_newline);
Array<Code> type_kinds = get_odin_type_kinds();
for (Code code = src_types_cpp.begin(); code != src_types_cpp.end(); ++ code) switch (code->Type)
{
case CT_Preprocess_Define:
{
if ( code->Name.starts_with( txt("TYPE_KINDS"))) {
// Skip, we don't want it.
continue;
}
if ( code->Name.starts_with( txt("TYPE_KIND"))) {
// Skip the next 3 definitions
++ code;
++ code;
continue;
}
body.append(code);
}
continue;
case CT_Enum:
{
if ( code->Name.starts_with( txt("TypeKind")))
{
CodeBody swap_body = def_body( CT_Enum_Body);
{
swap_body.append( code_str(Type_Invalid, ));
{
for (Code type : type_kinds)
swap_body.append( untyped_str( StrBuilder::fmt_buf(ctx.Allocator_Temp, "Type_%S,", type->Name )));
swap_body.append( code_str(Type_COUNT));
}
CodeEnum swapped_enum = cast(CodeEnum, code).duplicate();
swapped_enum->Body = swap_body;
body.append(swapped_enum);
}
}
else
body.append(code);
}
continue;
case CT_Variable:
{
if (code->Name.starts_with(txt("type_strings")))
{
#pragma push_macro("cast")
#undef cast
// Swap with generated table
StrBuilder generated_table = StrBuilder::make_reserve(ctx.Allocator_Temp, kilobytes(32));
{
for (Code type : type_kinds)
generated_table.append(token_fmt("type", (Str)type->Name, stringize(
{ cast(u8 *) "<type>", gb_size_of("<type>") -1 },
)));
}
CodeVar swapped_table = ((CodeVar)code).duplicate();
swapped_table->Value = code_fmt( "types", (Str)generated_table, stringize(
{
{ cast(u8 *)"invalid node", gb_size_of("invalid node")},\n
<types>
}));
#pragma pop_macro("cast")
body.append(swapped_table);
body.append(fmt_newline);
// Right after is where the struct definitions were defined, we'll insert them here
body.append(def_pragma(txt("region TYPE_KINDS")));
body.append(fmt_newline);
for (Code type : type_kinds)
{
Code def = type.duplicate();
def->Name = cache_str( StrBuilder::fmt_buf(ctx.Allocator_Temp, "Type%S", type->Name));
body.append( def );
body.append(fmt_newline);
}
body.append(def_pragma(txt("endregion TYPE_KINDS")));
continue;
}
body.append(code);
}
continue;
case CT_Struct:
{
CodeStruct code_struct = cast(CodeStruct, code);
if ( str_are_equal(code->Name, txt("Type")))
for (Code type_code : code_struct->Body) switch (type_code->Type)
{
case CT_Union:
{
// Swap out the union's contents with the generated member definitions
CodeBody body_swap = def_body(CT_Union_Body);
for (Code type : type_kinds)
body_swap.append( parse_variable( token_fmt( "name", (Str)type->Name, stringize(
Type<name> <name>;
))));
type_code->Body = body_swap;
}
break;
default:
continue;
}
body.append(code);
}
continue;
default:
body.append(code);
continue;
}
Builder src = Builder::open( path_src "types.cpp" );
src.print(body);
src.write();
format_file( path_src "types.cpp" );
}
// gen::deinit();
return 0;
}
+58
View File
@@ -0,0 +1,58 @@
## Navigation
[Top](../Readme.md)
<- [docs - General](Readme.md)
## Current Design
`AST` is the actual managed node object for the library.
Its raw and really not meant to be used directly.
All user interaction must be with its pointer so the type they deal with is `AST*`.
In order to abstract away constant use of `AST*` its wrapped in a Code type which can be either:
When its the [C generated variant of the library](../gen_c_library/)
```c
typedef AST* Code;
tyepdef AST_<name>* Code<name>;
...
```
**or**
For C++:
```cpp
struct Code {
AST* ast;
};
struct Code<name> {
...
AST_<name>* ast;
};
```
The full definitions of all asts are within:
* [`ast.hpp`](../base/components/ast.hpp)
* [`ast_types.hpp`](../base/components/ast_types.hpp)
* [`code_types.hpp`](../base/components/code_types.hpp)
The C/C++ interface procedures are located with `ast.hpp` (for the Code type), and `code_types.hpp` for all others.
## Serialization
All code types can either serialize using a function of the pattern:
```c
StrBuilder <prefix>_to_strbuilder(Code code);
// or
<prefix>_to_strbuilder(Code code, StrBuilder& result);
```
Where the first generates strings allocated using Allocator_StringArena and the other appends an existing strings with their backed allocator.
Serialization of for the AST is defined for `Code` in [`ast.chpp`](../base/components/ast.cpp) with `code_to_strbuilder_ptr` & `code_to_strbuilder`.
Serializtion for the rest of the code types is within [`code_serialization.cpp`](../base/components/code_serialization.cpp).
Gencpp's serialization does not provide coherent formatting of the code. The user should use a formatter after serializing.
+765
View File
@@ -0,0 +1,765 @@
## Navigation
[Top](../Readme.md)
<- [docs - General](Readme.md)
# AST Types Documentation
While the Readme for docs covers the data layout per AST, this will focus on the AST types avaialble, and their nuances.
## Body
These are containers representing a scope body of a definition that can be of the following `CodeType` type:
* Class_Body
* Enum_Body
* Export_Body
* Extern_Linkage_Body
* Function_Body
* Global_Body
* Namespace_Body
* Struct_Body
* Union_Body
Fields:
```cpp
StrCached Name;
Code Front;
Code Back;
Token* Tok;
Code Parent;
CodeT Type;
s32 NumEntries;
```
The `Front` member represents the start of the link list and `Back` the end.
NumEntries is the number of entries in the body.
Parent should have a compatible CodeType type for the type of defintion used.
Serialization:
Will output only the entries, the braces are handled by the parent.
```cpp
<Front>
...
<Back>
```
## Attributes
Represent standard or vendor specific C/C++ attributes.
Fields:
```cpp
StrCached Content;
StrCached Name;
Code Prev;
Code Next;
Token* Tok;
Code Parent;
CodeT Type;
```
Serialization:
```cpp
<Content>
```
While the parser supports the `__declspec` and `__attribute__` syntax, the upfront constructor ( def_attributes ) must have the user specify the entire attribute, including the `[[]]`, `__declspec` or `__attribute__` parts.
## Comment
Stores a comment.
Fields:
```cpp
StrCached Content;
StrCached Name;
Code Prev;
Code Next;
Token* Tok;
Code Parent;
CodeT Type;
```
Serialization:
```cpp
<Content>
```
The parser will perserve comments found if residing with a body or in accepted inline-to-definition locations.
Otherwise they will be skipped by the TokArray::__eat and TokArray::current( skip foramtting enabled ) functions.
The upfront constructor: `def_comment` expects to recieve a comment without the `//` or `/* */` parts. It will add them during construction.
## Class & Struct
Fields:
```cpp
CodeComment InlineCmt; // Only supported by forward declarations
CodeAttributes Attributes;
CodeType ParentType;
CodeBody Body;
StrCached Name;
CodeType Prev;
CodeType Next;
Token* Tok;
Code Parent;
CodeT Type;
ModuleFlag ModuleFlags;
AccessSpec ParentAccess;
```
Serialization:
```cpp
// Class_Fwd
<ModuleFlags> <class/struct> <Name>; <InlineCmt>
// Class
<ModuleFlags> <class/struct> <Attributes> <Name> : <ParentAccess> <ParentType>, public <ParentType->Next>, ... <InlineCmt>
{
<Body>
};
```
You'll notice that only one parent type is supported only with parent access. This library only supports single inheritance, the rest are assumed to be interfaces and are given public acess specifiers.
## Constructor
Fields:
```cpp
CodeComment InlineCmt; // Only supported by forward declarations
Code InitializerList;
CodeParams Params;
Code Body;
StrCached Name;
Code Prev;
Code Next;
Token* Tok;
Code Parent;
CodeT Type;
```
Serialization:
```cpp
// Constructor_Fwd
<Specs> <Parent->Name>( <Params> ); <InlineCmt>
// Constructor
<Specs> <Parent->Name>( <Params> ) <InlineCmt>
: <InitializerList>
{
<Body>
}
// Constructor Source Implementation
<Specs> <Parent>::~<Parent->Name>( <Params> ) <Specs>
{
<Body>
}
```
## Define
Represents a preprocessor define
Fields:
```cpp
StrCached Content;
StrCached Name;
Code Prev;
Code Next;
Token* Tok;
Code Parent;
CodeT Type;
```
Serialization:
```cpp
#define <Name> <Content>
```
## Destructor
Fields:
```cpp
CodeComment InlineCmt;
CodeSpecifiers Specs;
Code Body;
StrCached Name;
Code Prev;
Code Next;
Token* Tok;
Code Parent;
CodeT Type;
```
Serialization:
```cpp
// Destructor_Fwd
<Specs> ~<Parent->Name>( <Params> ) <Specs>; <InlineCmt>
// Destructor
<Specs> ~<Parent->Name>( <Params> ) <Specs>
{
<Body>
}
// Destructor Source Implementation
<Specs> <Parent>::~<Parent->Name>( <Params> ) <Specs>
{
<Body>
}
```
## Enum
Fields:
```cpp
CodeComment InlineCmt;
CodeAttributes Attributes;
CodeType UnderlyingType;
Code UnderlyingTypeMacro;
CodeBody Body;
Code Prev;
Code Next;
Token* Tok;
Code Parent;
StrCached Name;
CodeT Type;
ModuleFlag ModuleFlags;
```
UnderlyingTypeMacro is a macro the library natively supports: `enum_underlying(type)` that is meant to behave as a wrapper for underlying type assignment.
The `enum_underlying_sig` is a `Str` global var that can be set which will be defined within `PreprocessorDefines` and used in `parser_parse_enum` to identify a valid macro.
Serialization:
```cpp
// Enum_Fwd
<ModuleFlags> enum class <Name> : <UnderlyingType> or <UnderlyingTypeMacro> ; <InlineCmt>
// Enum
<ModuleFlags> <enum or enum class> <Name> : <UnderlyingType> or <UnderlyingTypeMacro>
{
<Body>
};
```
## Execution
Just represents an execution body. Equivalent to an untyped body.
Will be obsolute when function body parsing is implemented.
Fields:
```cpp
StrCached Content;
StrCached Name;
Code Prev;
Code Next;
Token* Tok;
Code Parent;
CodeT Type;
```
Serialization:
```cpp
<Content>
```
## External Linkage
Fields:
```cpp
CodeBody Body;
StrCached Name;
Code Prev;
Code Next;
Token* Tok;
Code Parent;
CodeT Type;
```
Serialization:
```cpp
extern "<Name>"
{
<Body>
}
```
## Include
Fields:
```cpp
StrCached Content;
StrCached Name;
Code Prev;
Code Next;
Code Parent;
Token* Tok;
CodeT Type;
```
Serialization:
```cpp
#include <Content>
```
## Friend
This library (until its necessary become some third-party library to do otherwise) does not support friend declarations with in-statment function definitions.
Fields:
```cpp
CodeComment InlineCmt;
Code Declaration;
StrCached Name;
Code Prev;
Code Next;
Token* Tok;
Code Parent;
CodeT Type;
```
Serialization:
```cpp
friend <Declaration>; <InlineCmt>
```
## Function
Fields:
```cpp
CodeComment InlineCmt;
CodeAttributes Attributes;
CodeSpecifiers Specs;
CodeType ReturnType;
CodeParams Params;
CodeBody Body;
StrCached Name;
Code Prev;
Code Next;
Token* Tok;
Code Parent;
CodeT Type;
ModuleFlag ModuleFlags;
```
Serialization:
```cpp
// Function_Fwd
<ModuleFlags> <Attributes> <Specs> <ReturnType> <Name>( <Params> ) <Specs>; <InlineCmt>
// Function
<ModuleFlags> <Attributes> <Specs> <ReturnType> <Name>( <Params> ) <Specs>
{
<Body>
}
```
## Module
Fields:
```cpp
StrCached Name;
Code Prev;
Code Next;
Token* Tok;
Code Parent;
CodeT Type;
ModuleFlag ModuleFlags;
```
Serialization:
```cpp
<ModuleFlags> module <Name>;
```
## Namespace
Fields:
```cpp
CodeBody Body;
StrCached Name;
Code Prev;
Code Next;
Token* Tok;
Code Parent;
CodeT Type;
ModuleFlag ModuleFlags;
```
Serialization:
```cpp
<ModuleFlags> namespace <Name>
{
<Body>
}
```
## Operator Overload (Operator)
Fields:
```cpp
CodeComment InlineCmt;
CodeAttributes Attributes;
CodeSpecifiers Specs;
CodeType ReturnType;
CodeParams Params;
CodeBody Body;
StrCached Name;
Code Prev;
Code Next;
Token* Tok;
Code Parent;
CodeT Type;
ModuleFlag ModuleFlags;
OperatorT Op;
```
Serialization:
```cpp
// Operator_Fwd
<ModuleFlags> <Attributes> <Specs> <ReturnType> operator <Op>( <Params> ) <Specs>; <InlineCmt>
// Operator
<ModuleFlags> <Attributes> <Specs> <ReturnType> <Name>operator <Op>( <Params> ) <Specs>
{
<Body>
}
```
## Operator Cast Overload ( User-Defined Type Conversion, OpCast )
Fields:
```cpp
CodeComment InlineCmt;
CodeSpecifiers Specs;
CodeType ValueType;
CodeBody Body;
StrCached Name;
Code Prev;
Code Next;
Token* Tok;
Code Parent;
CodeT Type;
```
Serialization:
```cpp
// Operator_Cast_Fwd
<Specs> operator <ValueType>() <Specs>; <InlineCmt>
// Operator_Cast
<Specs> <Name>operator <ValueType>() <Specs>
{
<Body>
}
```
## Parameters (AST_Params)
Fields:
```cpp
CodeType ValueType;
Code Macro;
Code Value;
Code PostNameMacro;
StrCached Name;
CodeParams Last;
CodeParams Next;
Token* Tok;
Code Parent;
CodeT Type;
s32 NumEntries;
```
Serialization:
```cpp
<Macro>, <Next> ... <Last>
<Macro> <ValueType> <Name> <PostNameMacro> = <Value>, <Next>... <Last>
```
## Pragma
Fields:
```cpp
StrCached Content;
StrCached Name;
Code Prev;
Code Next;
Token* Tok;
Code Parent;
CodeT Type;
```
Serialization:
```cpp
#pragma <Content>
```
## Preprocessor Conditional
Fields:
```cpp
StrCached Content;
StrCached Name;
Code Prev;
Code Next;
Token* Tok;
Code Parent;
CodeT Type;
```
Serialization:
```cpp
#<based off Type> <Content>
```
## Specifiers
Fields:
```cpp
SpecifierT ArrSpecs[ AST_ArrSpecs_Cap ];
CodeSpecifiers NextSpecs;
StrCached Name;
Code Prev;
Code Next;
Token* Tok;
Code Parent;
CodeT Type;
s32 NumEntries;
```
Serialization:
```cpp
<Spec>, ...
```
## Template
Fields:
```cpp
CodeParams Params;
Code Declaration;
StrCached Name;
Code Prev;
Code Next;
Token* Tok;
Code Parent;
CodeT Type;
ModuleFlag ModuleFlags;
```
Serialization:
```cpp
<ModuleFlags>
template< <Params> >
<Declaration>
```
## Typename
Typenames represent the type "symbol".
Fields:
```cpp
CodeAttributes Attributes;
CodeSpecifiers Specs;
CodeReturnType ReturnType;
CodeParams Params;
Code ArrExpr;
Code Prev;
Code Next;
Token* Tok;
Code Parent;
StrCached Name;
CodeT Type;
b32 IsParamPack;
ETypenameTag TypeTag;
```
Serialization:
```cpp
<Attributes> <TypeTag> <Name> <Specs> <IsParamPack ?: ...>
// Function
<Attributes> <ReturnType> <Name> <Params> <Specs>
```
`<Name>` currently has the full serialization of anything with
*Note: ArrExpr is not used in serialization by `typename_to_strbuilder_ref` its instead handled by a parent AST's serailization (variable, typedef, using).*
## Typedef
Behave as usual except function or macro typedefs.
Those (macros) don't use the underlying type field as everything was serialized under the Name field.
Fields:
```cpp
CodeComment InlineCmt;
Code UnderlyingType;
StrCached Name;
Code Prev;
Code Next;
Token* Tok
Code Parent;
CodeT Type;
ModuleFlag ModuleFlags;
b32 IsFunction;
```
Serialization:
```cpp
// Regular
<ModuleFlags> typedef <UnderlyingType> <Name> <UnderlyingType-ArrExpr>; <InlineCmt>
// Functions
// Currently:
<ModuleFlags> typedef <UnderlyingType (Serialized expression)>; <InlineCmt>
// Desired: Not handled yet
<ModuleFlags> typedef <UnderlyingType->ReturnType> UnderlyingType->Name> <UnderlyingType-ArrExpr> ( <UnderlyingType->Parameters> ); <InlineCmt>
<ModuleFlags> typedef <UnderlyingType->ReturnType> ( <Name->Namespace> for<Specs->has(Spec_Ptr) ?: *> <UnderlyingType->Name> <UnderlyingType-ArrExpr> ) ( <UnderlyingType->Parameters> ); <InlineCmt>
```
## Union
Fields:
```cpp
CodeAttributes Attributes;
CodeBody Body;
StrCached Name;
Code Prev;
Code Next;
Token* Tok;
Code Parent;
CodeT Type;
ModuleFlag ModuleFlags;
```
Serialization:
```cpp
<ModuleFlags> union <Attributes> <Name>
{
<Body>
}
```
## Using
Fields:
```cpp
CodeComment InlineCmt;
CodeAttributes Attributes;
CodeType UnderlyingType;
StrCached Name;
Code Prev;
Code Next;
Token* Tok;
Code Parent;
CodeT Type;
ModuleFlag ModuleFlags;
```
Serialization:
```cpp
// Regular
<ModuleFlags> using <Attributes> <Name> = <UnderlyingType>; <InlineCmt>
// Namespace
<ModuleFlags> using namespace <Name>; <InlineCmt>
```
## Variable
[Algo](./Parser_Algo.md:)
Fields:
```cpp
CodeComment InlineCmt;
CodeAttributes Attributes;
CodeSpecifiers Specs;
CodeType ValueType;
Code BitfieldSize;
Code Value;
StrCached Name;
CodeVar NextVar;
Code Prev;
Code Next;
Token* Tok;
Code Parent;
CodeT Type;
ModuleFlag ModuleFlags;
s32 VarParenthesizedInit;
```
Serialization:
```cpp
// Regular
<ModuleFlags> <Attributes> <Specs> <ValueType> <Name> = <Value>, NextVar ...; <InlineCmt>
// Bitfield
<ModuleFlags> <Attributes> <Specs> <ValueType> <Name> : <BitfieldSize> = <Value>, NextVar ...; <InlineCmt>
// VarParenthesizedInit
<Attributes> <Specs> <ValueType> <Name>( <Value>, NextVar ... ); <InlineCmt>
```
+28
View File
@@ -0,0 +1,28 @@
BSD 3-Clause License
Copyright (c) 2023, Edward R. Gonzalez
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
3. Neither the name of the copyright holder nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+708
View File
@@ -0,0 +1,708 @@
## Navigation
[Top](../Readme.md)
<- [docs - General](Readme.md)
# Parser's Algorithim
gencpp uses a hand-written recursive descent parser. Both the lexer and parser currently handle a full C/C++ file in a single pass.
## Notable implementation background
### Lexer
The lex procedure does the lexical pass of content provided as a `Str` type.
The tokens are stored (for now) in `Lexer_Tokens`.
Fields:
```cpp
Array<Token> Arr;
s32 Idx;
```
What token types are supported can be found in [ETokType.csv](../base/enums/ETokType.csv) you can also find the token types in [ETokType.h](../base/components/gen/etoktype.cpp) , which is the generated enum from the csv file.
Tokens are defined with the struct `gen::parser::Token`:
Fields:
```cpp
char const* Text;
sptr Length;
TokType Type;
s32 Line;
s32 Column;
u32 Flags;
```
Flags is a bitfield made up of TokFlags (Token Flags):
* `TF_Operator` : Any operator token used in expressions
* `TF_Assign`
* Using statment assignment
* Parameter argument default value assignment
* Variable declaration initialization assignment
* `TF_Preprocess` : Related to a preprocessing directive
* `TF_Preprocess_Cond` : A preprocess conditional
* `TF_Attribute` : An attribute token
* `TF_AccessSpecifier` : An accesor operation token
* `TF_Specifier` : One of the specifier tokens
* `TF_EndDefinition` : Can be interpreted as an end definition for a scope.
* `TF_Formatting` : Considered a part of the formatting
* `TF_Literal` : Anything considered a literal by C++.
I plan to replace IsAssign with a general flags field and properly keep track of all operator types instead of abstracting it away to `ETokType::Operator`.
Traversing the tokens is done with the following interface macros:
| Macro | Description |
| --- | --- |
| `currtok_noskip` | Get the current token without skipping whitespace |
| `currtok` | Get the current token, skip any whitespace tokens |
| `prevtok` | Get the previous token (does not skip whitespace) |
| `nexttok` | Get the next token (does not skip whitespace) |
| `eat( Token Type )` | Check to see if the current token is of the given type, if so, advance Token's index to the next token |
| `left` | Get the number of tokens left in the token array |
| `check_noskip` | Check to see if the current token is of the given type, without skipping whitespace |
| `check` | Check to see if the current token is of the given type, skip any whitespace tokens |
### Parser
The parser has a limited user interface, only specific types of definitions or statements are expected to be provided by the user directly when using to construct an AST dynamically (See SOA for example). It however does attempt to provide capability to parse a full C/C++ from production codebases.
Each public user interface procedure has the following format:
```cpp
<code type> parse_<definition type>( Str def )
{
check_parse_args( def );
using namespace Parser;
TokArray toks = lex( def );
if ( toks.Arr == nullptr )
return CodeInvalid;
// Parse the tokens and return a constructed AST using internal procedures
...
}
```
The most top-level parsing procedure used for C/C++ file parsing is `parse_global_body`:
It uses a helper procedure called `parse_global_nspace`.
Each internal procedure will have the following format:
```cpp
internal
<code type> parse_<definition_type>( <empty or contextual params> )
{
push_scope();
...
<code type> result = (<code type>) make_code();
...
Context.pop();
return result;
}
```
Below is an outline of the general alogirithim used for these internal procedures. The intention is to provide a basic briefing to aid the user in traversing the actual code definitions. These appear in the same order as they are in the `parser.cpp` file
***NOTE: This is still heavily in an alpha state. A large swaph of this can change, make sure these docs are up to date before considering them 1:1 with the repo commit your considering.***
## `parse_array_decl`
1. Check if its an array declaration with no expression.
1. Consume and return empty array declaration
2. Opening square bracket
3. Consume expression
4. Closing square bracket
5. If adjacent opening bracket
1. Repeat array declaration parse until no brackets remain
## `parse_assignment_expression`
1. Eat the assignment operator
2. Make sure there is content or at least an end statement after.
3. Flatten the assignment expression to an untyped Code string.
## `parse_attributes`
1. Check for standard attribute
2. Check for GNU attribute
3. Check for MSVC attribute
4. Check for a token registered as an attribute
a. Check and grab the arguments of a token registered of an attribute if it has any.
5. Repeat for chained attributes. Flatten them to a single attribute AST node.
## `parse_class_struct`
1. Check for export module specifier
2. class or struct keyword
3. `parse_attributes`
4. If identifier : `parse_identifier`
5. Parse inherited parent or interfaces
6. If opening curly brace : `parse_class_struct_body`
7. If not an inplace definition
1. End statement
2. Check for inline comment
## `parse_class_struct_body`
1. Opening curly brace
2. Parse the body (Possible options):
1. Ignore dangling end statements
2. Newline : ast constant
3. Comment : `parse_comment`
4. Access_Public : ast constant
5. Access_Protected : ast constant
6. Access_Private : ast constant
7. Decl_Class : `parse_complicated_definition`
8. Decl_Enum : `parse_complicated_definition`
9. Decl_Friend : `parse_friend`
10. Decl_Operator : `parse_operator_cast`
11. Decl_Struct : `parse_complicated_definition`
12. Decl_Template : `parse_template`
13. Decl_Typedef : `parse_typedef`
14. Decl_Union : `parse_complicated_definition`
15. Decl_Using : `parse_using`
16. Operator == '~'
1. `parse_destructor`
17. Preprocess_Define : `parse_define`
18. Preprocess_Include : `parse_include`
19. Preprocess_Conditional (if, ifdef, ifndef, elif, else, endif) : `parse_preprocess_cond` or else/endif ast constant
20. Preprocess_Macro : `parse_simple_preprocess`
21. Preprocess_Pragma : `parse_pragma`
22. Preprocess_Unsupported : `parse_simple_preprocess`
23. StaticAssert : `parse_static_assert`
24. The following compound into a resolved definition or declaration:
1. Attributes (Standard, GNU, MSVC) : `parse_attributes`
2. Specifiers (consteval, constexpr, constinit, explicit, forceinline, inline, mutable, neverinline, static, volatile, virtual)
3. Possible Destructor : `parse_destructor`
4. Possible User defined operator cast : `parse_operator_cast`
5. Possible Constructor : `parse_constructor`
6. Something that has the following: (identifier, const, unsigned, signed, short, long, bool, char, int, double)
1. Possible Constructor `parse_constructor`
2. Possible Operator, Function, or varaible : `parse_operator_function_or_variable`
25. Something completely unknown (will just make untyped...) : `parse_untyped`
## `parse_comment`
1. Just wrap the token into a cached string ( the lexer did the processing )
## `parse_compilcated_definition`
This is a helper function used by the following functions to help resolve a declaration or definition:
* `parse_class_struct_body`
* `parse_global_nspace`
* `parse_union`
A portion of the code in `parse_typedef` is very similar to this as both have to resolve a similar issue.
1. Look ahead to the termination token (End statement)
2. Check to see if it fits the pattern for a forward declare
3. If the previous token was an identifier ( `token[-1]` ):
1. Look back one more token : `[-2]`
2. If the token has a closing brace its an inplace definition
3. If the `token[-2]` is an identifier & `token[-3]` is the declaration type, its a variable using a namespaced type.
4. If the `token[-2]` is an indirection, then its a variable using a namespaced/forwarded type.
5. If the `token[-2]` is an assign classifier, and the starting tokens were the which type with possible `class` token after, its an enum forward declaration.
6. If any of the above is the case, `parse_operator_function_or_variable`
4. If the `token[2]` is a vendor fundamental type (builtin) then it is an enum forward declaration.
5. If the previous token was a closing curly brace, its a definition : `parse_forward_or_definition`
6. If the previous token was a closing square brace, its an array definition : `parse_operator_function_or_variable`
## `parse_define`
1. Define directive
2. Get identifier
3. Get Content (Optional)
## `parse_forward_or_definition`
* Parse any of the following for either a forward declaration or definition:
1. Decl_Class : `parse_class`
2. Decl_Enum : `parse_enum`
3. Decl_Struct : `parse_struct`
4. Decl_Union : `parse_union`
## `parse_function_after_name`
This is needed as a function defintion is not easily resolvable early on, as such this function handles resolving a function
after its been made ceratin that the type of declaration or definition is indeed for a function signature.
By the point this function is called the following are known : export module flag, attributes, specifiers, return type, & name
1. `parse_parameters`
2. parse postfix specifiers (we do not check if the specifier here is correct or not to be here... yet)
3. If there is a body : `parse_body`
4. Otherwise :
1. Statment end
2. Check for inline comment
## `parse_function_body`
Currently there is no actual parsing of the function body. Any content with the braces is shoved into an execution AST node.
In the future statements and expressions will be parsed.
1. Open curly brace
2. Grab all tokens between the brace and the closing brace, shove them in a execution AST node.
3. Closing curly brace
## `parse_global_nspace`
1. Make sure this is being called for a valid type (namespace, global body, export body, linkage body)
2. If its not a global body, consume the opening curly brace
3. Parse the body (Possible options):
1. Ignore dangling end statements
2. NewLine : ast constant
3. Comment : `parse_comment`
4. Decl_Cass : `parse_complicated_definition`
5. Decl_Enum : `parse_complicated_definition`
6. Decl_Extern_Linkage : `parse_extern_link`
7. Decl_Namespace : `parse_namespace`
8. Decl_Struct : `parse_complicated_definition`
9. Decl_Template : `parse_template`
10. Decl_Typedef : `parse_typedef`
11. Decl_Union : `parse_complicated_definition`
12. Decl_Using : `parse_using`
13. Preprocess_Define : `parse_define`
14. Preprocess_Include : `parse_include`
15. Preprocess_If, IfDef, IfNotDef, Elif : `parse_preprocess_cond`
16. Preprocess_Else : ast constant
17. Preprocess_Endif : ast constant
18. Preprocess_Macro : `parse_simple_preprocess`
19. Preprocess_Pragma : `parse_pragma`
20. Preprocess_Unsupported : `parse_simple_preprocess`
21. StaticAssert : `parse_static_assert`
22. Module_Export : `parse_export_body`
23. Module_Import : NOT_IMPLEMENTED
24. The following compound into a resolved definition or declaration:
1. Attributes ( Standard, GNU, MSVC, Macro ) : `parse_attributes`
2. Specifiers ( consteval, constexpr, constinit, extern, forceinline, global, inline, internal_linkage, neverinline, static )
3. Is either ( identifier, const specifier, long, short, signed, unsigned, bool, char, double, int)
1. Attempt to parse as construtor or destructor : `parse_global_nspace_constructor_destructor`
2. If its an operator cast (definition outside class) : `parse_operator_cast`
3. Its an operator, function, or varaible : `parse_operator_function_or_varaible`
4. If its not a global body, consume the closing curly brace
## `parse_global_nspace_constructor_destructor`
1. Look ahead for the start of the arguments for a possible constructor/destructor
2. Go back past the identifier
3. Check to see if its a destructor by checking for the `~`
4. Continue the next token should be a `::`
5. Determine if the next valid identifier (ignoring possible template parameters) is the same as the first identifier of the function.
6. If it is we have either a constructor or destructor so parse using their respective functions (`parse_constructor`, `parse_destructor`).
## `parse_identifier`
This is going to get heavily changed down the line to have a more broken down "identifier expression" so that the qualifier, template args, etc, can be distinguished between the targeted identifier.
The function can parse all of them, however the AST node compresses them all into a string.
1. Consume first identifier
2. `parse_template_args`
3. While there is a static symbol accessor ( `::` )
1. Consume `::`
2. Consume member identifier
3. `parse_template args` (for member identifier)
4. If a `~` is encounted and the scope is for a destructor's identifier, do not consume it and return with what parsed.
## `parse_include`
1. Consume include directive
2. Consume the path
## `parse_operator_after_ret_type`
This is needed as a operator defintion is not easily resolvable early on, as such this function handles resolving a operator after its been made ceratin that the type of declaration or definition is indeed for a operator signature.
By the point this function is called the following are known : export module flag, attributes, specifiers, return type
1. If there is any qualifiers for the operator, parse them
2. Consume operator keyword
3. Determine the operator type (This will be offloaded to the lexer moreso than how it is now) & consume
4. `parse_params`
5. If there is no parameters this is operator is a member of pointer if its symbols is a *.
6. Parse postfix specifiers
7. If there is a opening curly brace, `parse function_body`
8. Otherwise: consume end statement, check for inline comment.
## `parse_operator_function_or_variable`
When this function is called, attribute and specifiers may have been resolved, however what comes next can still be either an operator, function, or varaible.
1. Check for preprocessor macro, if there is one : `parse_simple_preprocess`
2. `parse_type` (Does the bulk of the work)
3. Begin lookahead to see if we get qualifiers or we eventually find the operator declaration
4. If we find an operator keyword : `parse_operator_after_ret_type`
5. otherwise :
1. `parse_identifier`
2. If we se a opening parenthesis (capture start), its a function : `parse_function_after_name`
3. Its a variable : `parse_variable_after_name`
## `parse_pragma`
1. Consume pragma directive
2. Process the token content into cached string
## `parse_params`
1. Consume either a `(` or `<` based on `use_template_capture` arg
2. If the we immdiately find a closing token, consume it and finish.
3. If we encounter a varadic argument, consume it and return a `param_varadic` ast constant
4. `parse_type`
5. If we have a macro, parse it (Unreal has macros as tags to parameters and or as entire arguments).
6. So long as next token isn't a comma
a. If we have an identifier
1. Consume it
2. Check for assignment:
a. Consume assign operator
b. Parse the expression
7. While we continue to encounter commas
a. Consume them
b. Repeat steps 3 to 6.2.b
8. Consume the closing token
## `parse_preprocess_cond`
1. Parse conditional directive
2. Process directive's content expression
## `parse_simple_preprocess`
There is still decent room for improvement in this setup. Right now the entire macro's relevant tokens are shoved into an untyped AST. It would be better to store it instead in an `AST_Macro` node instead down the line.
1. Consume the macro token
2. Check for an opening curly brace
1. Consume opening curly brace
2. Until the closing curly is encountered consume all tokens.
3. If the parent context is a typedef
1. Check for end stement
1. Consume it
2. Consume potential inline comment
3. Otherwise do steps 3 to 3.1.2
4. Shove it all in an untyped string
## `parse_static_assert`
1. Consume static assert and opening curly brace
2. Consume all tokens until the the closing brace is reached.
3. Consume curly brace and end statement
4. Place all tokens within braces into a content for the assert.
## `parse_template_args`
This will get changed heavily once we have better support for typename expressions
1. Consume opening angle bracket
2. Consume all tokens until closing angle bracket
3. Consme closing angle bracket
4. Return the currtok with the ammended length.
## `parse_variable_after_name`
This is needed as a variable defintion is not easily resolvable early on, it takes a long evaluation period before its known that the declaration or definition is a variable. As such this function handles resolving a variable.
By the point this function is called the following are known : export module flag, attributes, specifiers, value type, name
1. If its an assignment, parse the assignment expression (currently to an untyped string)
2. If its an opening curly brace, parse the expression within (currnelty to an untyped stirng).
1. Consume the closing curly brace
3. If its a `:`, we're dealing with bitfield definition:
1. Consume the assign classifier
2. Consume the expression (currently to an untyped string)
4. If a comma is encountered : `parse_variable declaration_list`
5. Consume statement end
6. Check for inline comment
## `parse_variable_declaration_list`
1. Consume the comma
2. Parse specifiers
3. `parse_variable_after_name`
## `parse_class`
1. `parse_class_struct`
## `parse_constructor`
This currently doesn't support postfix specifiers (planning to in the future)
1. `parse_identifier`
2. `parse_parameters`
3. If currtok is a `:`
1. Consume `:`
2. Parse the initializer list
3. `parse_function_body`
4. If currtok is an opening curly brace
1. `parse_function_body`
5. Otherwise:
1. Consume statement end
2. Check for inline comment
## `parse_destructor`
1. Check for and consume virtual specifier
2. Check for the `~` operator
3. `parse_identifier`
4. Consume opening and closing parenthesis
5. Check for assignment operator:
1. Consume assignment op
2. Consume pure specifier `0`
6. If not pure virtual & currtok is opening curly brace:
1. `parse_function_body`
7. Otherwise:
1. Consume end statement
2. If currtok is comment : `parse_comment`
## `parse_enum`
1. Consume enum token
2. Check for and consume class token
3. `parse_attributes`
4. If there is an identifier consume it
5. Check for a `:`
1. Consume `:`
2. `parse_type`
6. If there is a body parse it (Consume `{`):
1. Newline : ast constant
2. Comment : `parse_comment`
3. Preprocess_Define : `parse_define`
4. Preprocess_Conditional (if, ifdef, ifndef, elif ) : `parse_preprocess_cond`
5. Preprocess_Else : ast constant
6. Preprocess_Endif : ast constant
7. Preprocess_Macro : `parse_simple_preprocess`
8. Preprocess_Pragma : `parse_pragma`
9. Preprocess_Unsupported : `parse_smple_preprocess`
10. An actual enum entry
1. Consume identifier
2. If there is an assignment operator:
1. Consume operator
2. Consume the expression (assigned to untyped string for now)
3. If a macro is encountered consume it (Unreal UMETA macro support)
3. If there is a comma, consume it
## `parse_export_body`
1. `parse_global_nspace`
## `parse_extern_link_body`
1. `parse_global_nspace`
## `parse_extern_link`
1. Consume Decl_Extern_Linkage
2. Consume the linkage identifier
3. `parse_extern_link_body`
## `parse_friend`
1. Consume `friend`
2. `parse_type`
3. If the currok is an identifier its a function declaration or definition
1. `parse_function_after_name`
4. Consume end statement so long as its not a function definion
5. Check for inline comment, `parse_comment` if exists
## `parse_function`
1. Check and parse for `export`
2. `parse_attributes`
3. Parse specifiers
4. `parse_type`
5. `parse_identifier`
6. `parse_function_after_name`
## `parse_namespace`
1. Consume namespace declaration
2. Parse identifier
3. `parse_global_namespace`
## `parse_operator`
1. Check for and parse export declaration
2. `parse_attributes`
3. Parse specifiers
4. `parse_type`
5. `parse_operator_after_ret_type`
## `parse_operator_cast`
1. Look for and parse a qualifier namespace for the cast (in-case this is defined outside the class's scope)
2. Consume operator declaration
3. `parse_type`
4. Consume opening and closing parethesis
5. Check for a const qualifiying specifier
6. Check to see if this is a definition (`{`)
1. Consume `{`
2. Parse body to untyped string (parsing statement and expressions not supported yet)
3. Consume `}`
7. Otherwise:
1. Consume end statement
2. Check for and consume comment : `parse_comment`
## `parse_struct`
1. `parse_class_struct`
## `parse_template`
Note: This currently doesn't support templated operator casts (going to need to add support for it)
1. Check for and parse export declaration
2. Consume template declaration
3. `parse_params`
4. Parse for any of the following:
1. Decl_Class : `parse_class`
2. Decl_Struct : `parse_struct`
3. Decl_Union : `parse_union`
4. Decl_Using : `parse_using`
5. The following compound into a resolved definition or declaration:
1. `parse_attributes`
2. Parse specifiers
3. Attempt to parse as constructor or destructor: `parse_global_nspace_constructor_destructor`
4. Otherwise: `parse_operator_function_or_variable`
## `parse_type`
This function's implementation is awful and not done correctly. It will most likely be overhauled in the future as I plan to segement the AST_Type into several AST varaints along with sub-types to help produce robust type expressions.
Hopefully I won't need to make authentic type expressions as I was hopeing to avoid that...
### Current Algorithim
Anything that is in the qualifier capture of the function typename is treated as an expression abstracted as an untyped string
1. `parse_attributes`
2. Parse specifiers
3. If the `parse_type` was called from a template parse, check to see if class was used instead of typname and consume as name.
4. This is where things get ugly for each of these depend on what the next token is.
1. If its an in-place definition of a class, enum, struct, or union:
2. If its a decltype (Not supported yet but draft impl there)
3. If its a compound native type expression (unsigned, char, short, long, int, float, dobule, etc )
4. Ends up being a regular type alias of an identifier
5. Parse specifiers (postfix)
6. We need to now look ahead to see If we're dealing with a function typename
7. If wer're dealing with a function typename:
1. Shove the specifiers, and identifier code we have so far into a return type typename's Name (untyped string)
1. Reset the specifiers code for the top-level typeanme
2. Check to see if the next token is an identifier:
1. `parse_identifier`
3. Check to see if the next token is capture start and is not the last capture ("qualifier capture"):
1. Consume `(`
2. Consume expresssion between capture
3. Consume `)`
4. `parse_params`
5. Parse postfix specifiers
8. Check for varaidic argument (param pack) token:
1. Consume varadic argument token
### WIP - Alternative Algorithim
Currently wrapped up via macro: `GEN_USE_NEW_TYPENAME_PARSING`
Anything that is in the qualifier capture of the function typename is treated as an expression abstracted as an untyped string
1. `parse_attributes`
2. Parse specifiers (prefix)
3. This is where things get ugly for each of these depend on what the next token is.
1. If its an in-place definition of a class, enum, struct, or union:
2. If its a decltype (Not supported yet but draft impl there)
3. If its a compound native type expression (unsigned, char, short, long, int, float, dobule, etc )
4. Ends up being a regular type alias of an identifier
4. Parse specifiers (postfix)
1. If any specifiers are found populate specifiers code with them.
5. We need to now look ahead to see If we're dealing with a function typename
6. If wer're dealing with a function typename:
1. Shove the specifiers, and identifier code we have so far into a return type typename's Name (untyped string)
1. Reset the specifiers code for the top-level typename
2. Check to see if the next token is an identifier:
1. `parse_identifier`
3. Check to see if the next token is capture start and is not the last capture ("qualifier capture"):
1. Consume `(`
2. Parse binding specifiers
3. `parse_identifier`
4. `parse_parameters` -> params_nested
5. Consume `)`
6. Construct a nested function typename definition for the qualifier `Name`
4. `parse_params` - > params
5. Parse postfix specifiers
7. Check for varaidic argument (param pack) token:
1. Consume varadic argument token
### **Later: Algorithim based on typename expressions**
## `parse_typedef`
1. Check for export module specifier
2. typedef keyword
3. If its a preprocess macro: Get the macro name
4. Else:
1. Check to see if its a complicated definition (in-place enum, class, struct, union)
2. If its a complicated definition:
1. Perform the look ahead similar to `parse_complicated_definition`'s implementation
2. Check to see if its a forward declaration : `parse_forward_declaration`
3. If end[-1] is an identifier:
1. Its either an in-place, varaible type qualified identifier, or indirection type:
1. `parse_foward_or_definition`
4. else if end[-1] is a closing curly brace
1. Its a definition: `parse_forward_or_definition`
5. else if end[-1] is a closing square brace
2. Its an array definition: `parse_type`
3. Else : `parse-type`
4. Check for identifier : Consume the token
5. `parse_array_decl`
5. Consume end statement
6. Check for inline comment : `parse_comment`
## `parse_union`
1. Check for export module specifier
2. union keyword
3. `parse_attributes`
4. Check for identifier
5. Parse the body (Possible options):
1. Newline
2. Comment
3. Decl_Class
4. Decl_Enum
5. Decl_Struct
6. Decl_Union
7. Preprocess_Define
8. Preprocess_Conditional (if, ifdef, ifndef, elif, else, endif)
9. Preprocess_Macro
10. Preprocess_Pragma
11. Unsupported preprocess directive
12. Variable
6. If its not an inplace definiton: End Statement
## `parse_using`
1. Check for export module specifier
2. using keyword
3. Check to see if its a using namespace
4. Get the identifier
5. If its a regular using declaration:
1. `parse_attributes`
2. `parse_type`
3. `parse_array_decl`
6. End statement
7. Check for inline comment
## `parse_variable`
1. Check for export module specifier
2. `parse_attributes`
3. `parse specifiers`
4. `parse_type`
5. `parse_identifier`
6. `parse_variable_after_name`
+98
View File
@@ -0,0 +1,98 @@
## Navigation
[Top](../Readme.md)
<- [docs - General](Readme.md)
# Parsing
The library features a naive single-pass parser tailored for only what the library needs to construct the supported syntax of C++ into its AST for *"front-end"* meta-programming purposes.
This parser does not, and should not do the compiler's job. By only supporting this minimal set of features, the parser is kept (so far) around ~7000 loc. I hope to keep it under 10k loc worst case.
You can think of this parser as *frontend parser* vs a *semantic parser*. Its intuitively similar to WYSIWYG. What you ***precerive*** as the syntax from the user-side before the compiler gets a hold of it, is what you get.
User exposed interface:
```cpp
CodeClass parse_class ( Str class_def );
CodeConstructor parse_constructor ( Str constructor_def );
CodeDestructor parse_destructor ( Str destructor_def );
CodeEnum parse_enum ( Str enum_def );
CodeBody parse_export_body ( Str export_def );
CodeExtern parse_extern_link ( Str exten_link_def );
CodeFriend parse_friend ( Str friend_def );
CodeFn parse_function ( Str fn_def );
CodeBody parse_global_body ( Str body_def );
CodeNS parse_namespace ( Str namespace_def );
CodeOperator parse_operator ( Str operator_def );
CodeOpCast parse_operator_cast( Str operator_def );
CodeStruct parse_struct ( Str struct_def );
CodeTemplate parse_template ( Str template_def );
CodeType parse_type ( Str type_def );
CodeTypedef parse_typedef ( Str typedef_def );
CodeUnion parse_union ( Str union_def );
CodeUsing parse_using ( Str using_def );
CodeVar parse_variable ( Str var_def );
```
To parse file buffers, use the `parse_global_body` function.
***Parsing will aggregate any tokens within a function body or expression statement to an untyped Code AST.***
Everything is done in one pass for both the preprocessor directives and the rest of the language.
The parser performs no macro expansion as the scope of gencpp feature-set is to only support the preprocessor for the goal of having rudimentary awareness of preprocessor ***conditionals***, ***defines***, ***includes***, and ***pragmas***.
The keywords supported for the preprocessor are:
* include
* define
* if
* ifdef
* elif
* endif
* pragma
Each directive `#` line is considered one preproecessor unit, and will be treated as one Preprocessor AST.
If a directive is used with an unsupported keyword its will be processed as an untyped AST.
The preprocessor lines are stored as members of their associated scope they are parsed within. ( Global, Namespace, Class/Struct )
***Again (Its not standard): These ASTs will be considered members or entries of braced scope they reside within***
Any preprocessor definition abuse that changes the syntax of the core language is unsupported and will fail to parse if not kept within an execution scope (function body, or expression assignment).
Exceptions:
* function signatures are allowed for a preprocessed macro: `neverinline MACRO() { ... }`
* Disable with: `#define GEN_PARSER_DISABLE_MACRO_FUNCTION_SIGNATURES`
* typedefs allow for a preprocessed macro: `typedef MACRO();`
* Disable with: `#define GEN_PARSER_DISABLE_MACRO_TYPEDEF`
* Macros can behave as typenames
* There is some macro support in paramters for functions or templates *(Specifically added to support parsing Unreal Engine source)*.
*(Exceptions are added on an on-demand basis)*
*(See functions `parse_operator_function_or_variable` and `parse_typedef` )*
Adding your own exceptions is possible by simply modifying the parser to allow for the syntax you need.
*Note: You could interpret this strictness as a feature. This would allow the user to see if their codebase or a third-party's codebase some some egregious preprocessor abuse.*
If a macro is not defined withint e scope of parsing a set of files, it can be defined beforehand by:
* Appending the [`PreprocessorDefines`](https://github.com/Ed94/gencpp/blob/a18b5b97aa5cfd20242065cbf53462a623cd18fa/base/components/header_end.hpp#L137) array.
* For functional macros a "(" just needs to be added after the name like: `<name>(` so that it will tokenize its arguments as part of the token during lexing.
* Defining a CodeDefine using `def_define`. The definition will be processed by the interface for user into `PreprocessorDefines`.
* This can be prevented by setting the optional prameter `dont_append_preprocess_defines`.
The lexing and parsing takes shortcuts from whats expected in the standard.
* Numeric literals are not checked for validity.
* The parse API treats any execution scope definitions with no validation and are turned into untyped Code ASTs. (There is a [todo](https://github.com/Ed94/gencpp/issues/49) to add support)
* *This includes the assignment of variables.*
* Attributes ( `[[]]` (standard), `__declspec` (Microsoft), or `__attribute__` (GNU) )
* Assumed to *come before specifiers* (`const`, `constexpr`, `extern`, `static`, etc) for a function or right afterthe return type.
* Or in the usual spot for class, structs, (*right after the declaration keyword*)
* typedefs have attributes with the type (`parse_type`)
* Parsing attributes can be extended to support user defined macros by defining `GEN_DEFINE_ATTRIBUTE_TOKENS` (see `gen.hpp` for the formatting)
* This is useful for example: parsing Unreal `Module_API` macros.
Empty lines used throughout the file are preserved for formatting purposes during ast serialization.
+18
View File
@@ -0,0 +1,18 @@
## Navigation
# base
[Top](../Readme.md)
* [docs](../docs/Readme.md)
# Singleheader
Creates a single header file version of the library using `singleheader.cpp`.
Follows the same convention seen in the gb, stb, and zpl libraries.
If using the library's provided build scripts:
```ps1
.\build.ps1 <compiler> <debug or omit> singleheader
```
+419
View File
@@ -0,0 +1,419 @@
# General Docs
[Top](../Readme.md)
Contains:
* [AST_Design](./AST_Design.md): Overview of ASTs
* [AST Types](./AST_Types.md): Listing of all AST types along with their Code type interface.
* [Parsing](./Parsing.md): Overview of the parsing interface.
* [Parser Algo](./Parser_Algo.md): In-depth breakdown of the parser's implementation.
### *CURRENTLY UNSUPPORTED*
**There is no support for validating expressions.**
Its a [todo](https://github.com/Ed94/gencpp/issues/49)
**Only trivial template support is provided.**
The intention is for only simple, non-recursive substitution.
The parameters of the template are treated like regular parameter AST entries.
This means that the typename entry for the parameter AST would be either:
* `class`
* `typename`
* A fundamental type, function, or pointer type.
***Concepts and Constraints are not supported***
Its a [todo](https://github.com/Ed94/gencpp/issues/21)
### Feature Macros:
* `GEN_DEFINE_ATTRIBUTE_TOKENS` : Allows user to define their own attribute macros for use in parsing.
* This can be generated using base.cpp.
* `GEN_DEFINE_LIBRARY_CORE_CONSTANTS` : Optional typename codes as they are non-standard to C/C++ and not necessary to library usage
* `GEN_DONT_ENFORCE_GEN_TIME_GUARD` : By default, the library ( gen.hpp/ gen.cpp ) expects the macro `GEN_TIME` to be defined, this disables that.
* `GEN_ENFORCE_STRONG_CODE_TYPES` : Enforces casts to filtered code types.
* `GEN_EXPOSE_BACKEND` : Will expose symbols meant for internal use only.
* `GEN_ROLL_OWN_DEPENDENCIES` : Optional override so that user may define the dependencies themselves.
* `GEN_DONT_ALLOW_INVALID_CODE` (Not implemented yet) : Will fail when an invalid code is constructed, parsed, or serialized.
* `GEN_C_LIKE_PP` : Setting to `<true or 1>` Will prevent usage of function defnitions using references and structs with member functions. Structs will still have user-defined operator conversions, for-range support, and other operator overloads
### The Data & Interface
As mentioned in root readme, the user is provided Code objects by calling the constructor's functions to generate them or find existing matches.
The AST is managed by the library and provided to the user via its interface.
However, the user may specifiy memory configuration.
[Data layout of AST struct (Subject to heavily change with upcoming todos)](../base/components/ast.hpp#L396-461)
https://github.com/Ed94/gencpp/blob/eea4ebf5c40d5d87baa465abfb1be30845b2377e/base/components/ast.hpp#L396-L461
*`StringCahced` is a typedef for `Str` (a string slice), to denote it is an interned string*
*`CodeType` is enum taggin the type of code. Has an underlying type of `u32`*
*`OperatorT` is a typedef for `EOperator::Type` which has an underlying type of `u32`*
*`StrBuilder` is the dynamically allocated string type for the library*
AST widths are setup to be AST_POD_Size.
The width dictates how much the static array can hold before it must give way to using an allocated array:
```cpp
constexpr static
int AST_ArrSpecs_Cap =
(
AST_POD_Size
- sizeof(Code)
- sizeof(StrCached)
- sizeof(Code) * 2
- sizeof(Token*)
- sizeof(Code)
- sizeof(CodeType)
- sizeof(ModuleFlag)
- sizeof(u32)
)
/ sizeof(Specifier) - 1;
```
*Ex: If the AST_POD_Size is 128 the capacity of the static array is 20.*
Data Notes:
* The allocator definitions used are exposed to the user incase they want to dictate memory usage
* You'll find the memory handling in `init`, `deinit`, `reset`, `gen_strbuilder_allocator`, `cache_str`, `make_code`.
* Allocators are defined with the `AllocatorInfo` structure found in [`memory.hpp`](../base/dependencies/memory.hpp)
* Most of the work is just defining the allocation procedure:
```cpp
void* ( void* allocator_data, AllocType type, ssize size, ssize alignment, void* old_memory, ssize old_size, u64 flags );
```
* ASTs are wrapped for the user in a Code struct which is a wrapper for a AST* type.
* Code types have member symbols but their data layout is enforced to be POD types.
* This library treats memory failures as fatal.
* Cached Strings are stored in their own set of arenas. AST constructors use cached strings for names, and content.
* `StringArenas`, `StringCache`, `Allocator_StringArena`, and `Allocator_StringTable` are the associated containers or allocators.
* Strings used for serialization and file buffers are not contained by those used for cached strings.
* They are currently using `FallbackAllocator`, which are tracked array of arenas that grows as needed (adds buckets when one runs out).
* Memory within the buckets is not reused, so its inherently wasteful.
* I will be augmenting the default allocator with virtual memory & a slab allocator in the [future](https://github.com/Ed94/gencpp/issues/12)
* Intrusive linked lists used children nodes on bodies, and parameters.
* Its intended to generate the AST in one go and serialize after. The constructors and serializer are designed to be a "one pass, front to back" setup.
* Allocations can be tuned by defining the folloiwng macros (will be moved to runtime configuration in the future):
* `GEN_GLOBAL_BUCKET_SIZE` : Size of each bucket area for the global allocator
* `GEN_CODEPOOL_NUM_BLOCKS` : Number of blocks per code pool in the code allocator
* `GEN_SIZE_PER_STRING_ARENA` : Size per arena used with string caching.
* `GEN_MAX_COMMENT_LINE_LENGTH` : Longest length a comment can have per line.
* `GEN_MAX_NAME_LENGTH` : Max length of any identifier.
* `GEN_MAX_UNTYPED_STR_LENGTH` : Max content length for any untyped code.
* `TokenMap_FixedArena` : token_fmt_va uses local_persit memory of this arena type for the hashtable.
* `GEN_LEX_ALLOCATOR_SIZE`
* `GEN_BUILDER_STR_BUFFER_RESERVE`
The following CodeTypes are used which the user may optionally use strong typing with if they enable: `GEN_ENFORCE_STRONG_CODE_TYPES`
* CodeBody : Has support for `for : range` iterating across Code objects.
* CodeAttributes
* CodeComment
* CodeClass
* CodeConstructor
* CodeDefine
* CodeDestructor
* CodeEnum
* CodeExec
* CodeExtern
* CodeInclude
* CodeFriend
* CodeFn
* CodeModule
* CodeNS
* CodeOperator
* CodeOpCast
* CodeParams : Has support for `for : range` iterating across parameters.
* CodePreprocessCond
* CodePragma
* CodeSpecifiers : Has support for `for : range` iterating across specifiers.
* CodeStruct
* CodeTemplate
* CodeTypename
* CodeTypedef
* CodeUnion
* CodeUsing
* CodeVar
Each Code boy has an associated "filtered AST" with the naming convention: `AST_<CodeName>`
Unrelated fields of the AST for that node type are omitted and only necessary padding members are defined otherwise.
Retrieving a raw version of the ast can be done using the `raw()` function defined in each AST.
## There are three sets of interfaces for Code AST generation the library provides
* Upfront
* Parsing
* Untyped
### Upfront Construction
All component ASTs must be previously constructed, and provided on creation of the code AST.
The construction will fail and return CodeInvalid otherwise.
Interface :``
* def_attributes
* *This is pre-appended right before the function symbol, or placed after the class or struct keyword for any flavor of attributes used.*
* *Its up to the user to use the desired attribute formatting: `[[]]` (standard), `__declspec` (Microsoft), or `__attribute__` (GNU).*
* def_comment
* def_class
* def_constructor
* def_define
* def_destructor
* def_enum
* def_execution
* *This is equivalent to untyped_str, except that its intended for use only in execution scopes.*
* def_extern_link
* def_friend
* def_function
* def_include
* def_module
* def_namespace
* def_operator
* def_operator_cast
* def_param
* def_params
* def_pragma
* def_preprocess_cond
* def_specifier
* def_specifiers
* def_struct
* def_template
* def_type
* def_typedef
* def_union
* def_using
* def_using_namespace
* def_variable
Bodies:
* def_body
* def_class_body
* def_enum_body
* def_export_body
* def_extern_link_body
* def_function_body
* *Use this for operator bodies as well*
* def_global_body
* def_namespace_body
* def_struct_body
* def_union_body
Usage:
```cpp
<name> = def_<function type>( ... );
Code <name>
{
...
<name> = def_<function name>( ... );
}
```
When using the body functions, its recommended to use the args macro to auto determine the number of arguments for the varadic:
```cpp
def_global_body( args( ht_entry, array_ht_entry, hashtable ));
// instead of:
def_global_body( 3, ht_entry, array_ht_entry, hashtable );
```
If a more incremental approach is desired for the body ASTs, `Code def_body( CodeT type )` can be used to create an empty body.
When the members have been populated use: `AST::validate_body` to verify that the members are valid entires for that type.
### Parse construction
A string provided to the API is parsed for the intended language construct.
Interface :
* parse_class
* parse_constructor
* parse_destructor
* parse_enum
* parse_export_body
* parse_extern_link
* parse_friend
* Purposefully are only support forward declares with this constructor.
* parse_function
* parse_global_body
* parse_namespace
* parse_operator
* parse_operator_cast
* parse_struct
* parse_template
* parse_type
* parse_typedef
* parse_union
* parse_using
* parse_variable
Usage:
```cpp
Code <name> = parse_<function name>( string with code );
Code <name> = def_<function name>( ..., parse_<function name>(
<string with code>
));
```
### Untyped constructions
Code ASTs are constructed using unvalidated strings.
Interface :
* token_fmt_va
* token_fmt
* untyped_str
* untyped_fmt
* untyped_token_fmt
During serialization any untyped Code AST has its string value directly injected inline of whatever context the content existed as an entry within.
Even though these are not validated from somewhat correct c/c++ syntax or components, it doesn't mean that Untyped code can be added as any component of a Code AST:
* Untyped code cannot have children, thus there cannot be recursive injection this way.
* Untyped code can only be a child of a parent of body AST, or for values of an assignment (ex: variable assignment).
These restrictions help prevent abuse of untyped code to some extent.
Usage Conventions:
```cpp
Code <name> = def_variable( <type>, <name>, untyped_<function name>(
<string with code>
));
Code <name> = untyped_str( code(
<some code without "" quotes>
));
```
Optionally, `code_str`, and `code_fmt` macros can be used so that the code macro doesn't have to be used:
```cpp
Code <name> = code_str( <some code without "" quotes > )
```
Template metaprogramming in the traditional sense becomes possible with the use of `token_fmt` and parse constructors:
```cpp
Str value = txt("Something");
char const* template_str = txt(
Code with <key> to replace with token_values
...
);
char const* gen_code_str = token_fmt( "key", value, template_str );
Code <name> = parse_<function name>( gen_code_str );
```
## Predefined Codes
The following are provided predefined by the library as they are commonly used:
* `access_public`
* `access_protected`
* `access_private`
* `attrib_api_export`
* `attrib_api_import`
* `module_global_fragment`
* `module_private_fragment`
* `fmt_newline`
* `pragma_once`
* `param_varaidc` (Used for varadic definitions)
* `preprocess_else`
* `preprocess_endif`
* `spec_const`
* `spec_consteval`
* `spec_constexpr`
* `spec_constinit`
* `spec_extern_linkage` (extern)
* `spec_final`
* `spec_forceinline`
* `spec_global` (global macro)
* `spec_inline`
* `spec_internal_linkage` (internal macro)
* `spec_local_persist` (local_persist macro)
* `spec_mutable`
* `spec_neverinline`
* `spec_noexcept`
* `spec_override`
* `spec_ptr`
* `spec_pure`
* `spec_ref`
* `spec_register`
* `spec_rvalue`
* `spec_static_member` (static)
* `spec_thread_local`
* `spec_virtual`
* `spec_volatile`
* `t_empty` (Used for varaidc macros)
* `t_auto`
* `t_void`
* `t_int`
* `t_bool`
* `t_char`
* `t_wchar_t`
* `t_class`
* `t_typename`
Optionally the following may be defined if `GEN_DEFINE_LIBRARY_CODE_CONSTANTS` is defined
* `t_b32`
* `t_s8`
* `t_s16`
* `t_s32`
* `t_s64`
* `t_u8`
* `t_u16`
* `t_u32`
* `t_u64`
* `t_ssize` (ssize_t)
* `t_usize` (size_t)
* `t_f32`
* `t_f64`
## Extent of operator overload validation
The AST and constructors will be able to validate that the arguments provided for the operator type match the expected form:
* If return type must match a parameter
* If number of parameters is correct
* If added as a member symbol to a class or struct, that operator matches the requirements for the class (types match up)
* There is no support for validating new & delete operations (yet)
The user is responsible for making sure the code types provided are correct
and have the desired specifiers assigned to them beforehand.
## Code generation and modification
There are two provided auxillary interfaces:
* Builder
* Scanner
### Builder is a similar object to the jai language's strbuilder_builder
* The purpose of it is to generate a file.
* A file is specified and opened for writing using the open( file_path) function.
* The code is provided via print( code ) function will be serialized to its buffer.
* When all serialization is finished, use the write() command to write the buffer to the file.
### Scanner Auxillary Interface
* The purpose is to scan or parse files
* Some with two basic functions to convert a fil to code: `scan_file` and `parse_file`
* `scan_file`: Merely grabs the file and stores it in an untyped Code.
* `parse_file`: Will parse the file using `parse_global_body` and return a `CodeBody`.
* Two basic functions for grabbing columns from a CSV: `parse_csv_one_column` and `parse_csv_two_columns`
+26666
View File
File diff suppressed because it is too large Load Diff
+127
View File
@@ -0,0 +1,127 @@
Invalid, "Invalid"
EOF, "EOF"
Comment, "Comment"
FileTag, "FileTag"
_LiteralBegin, " "
Ident, "identifier"
Integer, "integer"
Float, "float"
Imag, "imaginary"
Rune, "rune"
String, "string"
_LiteralEnd, " "
_OperatorBegin, " "
Eq, "="
Not, "!"
Hash, "#"
At, "@"
Dollar, "$"
Pointer, "^"
Question, "?"
Add, "+"
Sub, "-"
Mul, "*"
Quo, "/"
Mod, "%"
ModMod, "%%"
And, "&"
Or, "|"
Xor, "~"
AndNot, "&~"
Shl, "<<"
Shr, ">>"
CmpAnd, "&&"
CmpOr, "||"
_AssignOpBegin, " "
AddEq, "+="
SubEq, "-="
MulEq, "*="
QuoEq, "/="
ModEq, "%="
ModModEq, "%%="
AndEq, "&="
OrEq, "|="
XorEq, "~="
AndNotEq, "&~="
ShlEq, "<<="
ShrEq, ">>="
CmpAndEq, "&&="
CmpOrEq, "||="
_AssignOpEnd, " "
Increment, "++"
Decrement, "--"
ArrowRight, "->"
Uninit, "---"
_ComparisonBegin, " "
CmpEq, "=="
NotEq, "!="
Lt, "<"
Gt, ">"
LtEq, "<="
GtEq, ">="
_ComparisonEnd, " "
OpenParen, "("
CloseParen, ")"
OpenBracket, "["
CloseBracket, "]"
OpenBrace, "{"
CloseBrace, "}"
Colon, ":"
Semicolon, ";"
Period, "."
Comma, ","
Ellipsis, ".."
RangeFull, "..="
RangeHalf, "..<"
BackSlash, "\\"
_OperatorEnd, " "
_KeywordBegin, " "
import, "import"
foreign, "foreign"
package, "package"
typeid, "typeid"
when, "when"
where, "where"
if, "if"
else, "else"
for, "for"
switch, "switch"
in, "in"
not_in, "not_in"
do, "do"
case, "case"
break, "break"
continue, "continue"
fallthrough, "fallthrough"
defer, "defer"
return, "return"
proc, "proc"
struct, "struct"
union, "union"
enum, "enum"
bit_set, "bit_set"
bit_field, "bit_field"
map, "map"
dynamic, "dynamic"
auto_cast, "auto_cast"
cast, "cast"
transmute, "transmute"
distinct, "distinct"
using, "using"
context, "context"
or_else, "or_else"
or_return, "or_return"
or_break, "or_break"
or_continue, "or_continue"
asm, "asm"
matrix, "matrix"
_KeywordEnd, " "
Count, " "
1 Invalid Invalid
2 EOF EOF
3 Comment Comment
4 FileTag FileTag
5 _LiteralBegin
6 Ident identifier
7 Integer integer
8 Float float
9 Imag imaginary
10 Rune rune
11 String string
12 _LiteralEnd
13 _OperatorBegin
14 Eq =
15 Not !
16 Hash #
17 At @
18 Dollar $
19 Pointer ^
20 Question ?
21 Add +
22 Sub -
23 Mul *
24 Quo /
25 Mod %
26 ModMod %%
27 And &
28 Or |
29 Xor ~
30 AndNot &~
31 Shl <<
32 Shr >>
33 CmpAnd &&
34 CmpOr ||
35 _AssignOpBegin
36 AddEq +=
37 SubEq -=
38 MulEq *=
39 QuoEq /=
40 ModEq %=
41 ModModEq %%=
42 AndEq &=
43 OrEq |=
44 XorEq ~=
45 AndNotEq &~=
46 ShlEq <<=
47 ShrEq >>=
48 CmpAndEq &&=
49 CmpOrEq ||=
50 _AssignOpEnd
51 Increment ++
52 Decrement --
53 ArrowRight ->
54 Uninit ---
55 _ComparisonBegin
56 CmpEq ==
57 NotEq !=
58 Lt <
59 Gt >
60 LtEq <=
61 GtEq >=
62 _ComparisonEnd
63 OpenParen (
64 CloseParen )
65 OpenBracket [
66 CloseBracket ]
67 OpenBrace {
68 CloseBrace }
69 Colon :
70 Semicolon ;
71 Period .
72 Comma ,
73 Ellipsis ..
74 RangeFull ..=
75 RangeHalf ..<
76 BackSlash \\
77 _OperatorEnd
78 _KeywordBegin
79 import import
80 foreign foreign
81 package package
82 typeid typeid
83 when when
84 where where
85 if if
86 else else
87 for for
88 switch switch
89 in in
90 not_in not_in
91 do do
92 case case
93 break break
94 continue continue
95 fallthrough fallthrough
96 defer defer
97 return return
98 proc proc
99 struct struct
100 union union
101 enum enum
102 bit_set bit_set
103 bit_field bit_field
104 map map
105 dynamic dynamic
106 auto_cast auto_cast
107 cast cast
108 transmute transmute
109 distinct distinct
110 using using
111 context context
112 or_else or_else
113 or_return or_return
114 or_break or_break
115 or_continue or_continue
116 asm asm
117 matrix matrix
118 _KeywordEnd
119 Count
+136
View File
@@ -0,0 +1,136 @@
/*
TYPE_KINDS swap content
These are not to be used directly. They are parsed by gen_src.cpp
*/
typedef BasicType Basic;
typedef TypeNamed Named;
// struct Named {
// String name;
// Type *base;
// Entity *type_name; /* Entity_TypeName */
// BlockingMutex gen_types_data_mutex;
// GenTypesData *gen_types_data;
// };
struct Generic {
i64 id;
String name;
Type *specialized;
Scope *scope;
Entity *entity;
};
struct Pointer {
Type *elem;
};
struct MultiPointer {
Type *elem;
};
struct Array {
Type *elem;
i64 count;
Type *generic_count;
};
struct EnumeratedArray {
Type *elem;
Type *index;
ExactValue *min_value;
ExactValue *max_value;
i64 count;
TokenKind op;
bool is_sparse;
};
struct Slice {
Type *elem;
};
struct DynamicArray {
Type *elem;
};
struct Map {
Type *key;
Type *value;
Type *lookup_result_type;
Type *debug_metadata_type;
};
typedef TypeStruct Struct;
typedef TypeUnion Union;
struct Enum {
Array<Entity *> fields;
Ast *node;
Scope *scope;
Type *base_type;
ExactValue *min_value;
ExactValue *max_value;
isize min_value_index;
isize max_value_index;
};
struct Tuple {
Slice<Entity *> variables; /* Entity_Variable */
i64 *offsets;
BlockingMutex mutex; /* for settings offsets */
std::atomic<bool> are_offsets_being_processed;
bool are_offsets_set;
bool is_packed;
};
typedef TypeProc Proc;
struct BitSet {
Type *elem;
Type *underlying;
i64 lower;
i64 upper;
Ast *node;
};
struct SimdVector {
i64 count;
Type *elem;
Type *generic_count;
};
struct RelativePointer {
Type *pointer_type;
Type *base_integer;
};
struct RelativeMultiPointer {
Type *pointer_type;
Type *base_integer;
};
struct Matrix {
Type *elem;
i64 row_count;
i64 column_count;
Type *generic_row_count;
Type *generic_column_count;
i64 stride_in_bytes;
bool is_row_major;
};
struct BitField {
Scope *scope;
Type *backing_type;
Slice<Entity *> fields;
String *tags; /*count == fields.count*/
Slice<u8> bit_sizes;
Slice<i64> bit_offsets;
Ast *node;
};
struct SoaPointer {
Type* elem;
};
+2
View File
@@ -0,0 +1,2 @@
// Wraps an `io.Stream` interface to provide buffered I/O.
package bufio
+7 -3
View File
@@ -29,14 +29,16 @@ MIN_READ_BUFFER_SIZE :: 16
@(private)
DEFAULT_MAX_CONSECUTIVE_EMPTY_READS :: 128
reader_init :: proc(b: ^Reader, rd: io.Reader, size: int = DEFAULT_BUF_SIZE, allocator := context.allocator) {
// reader_init initializes using an `allocator`
reader_init :: proc(b: ^Reader, rd: io.Reader, size: int = DEFAULT_BUF_SIZE, allocator := context.allocator, loc := #caller_location) {
size := size
size = max(size, MIN_READ_BUFFER_SIZE)
reader_reset(b, rd)
b.buf_allocator = allocator
b.buf = make([]byte, size, allocator)
b.buf = make([]byte, size, allocator, loc)
}
// reader_init initializes using a user provided bytes buffer `buf`
reader_init_with_buf :: proc(b: ^Reader, rd: io.Reader, buf: []byte) {
reader_reset(b, rd)
b.buf_allocator = {}
@@ -49,10 +51,12 @@ reader_destroy :: proc(b: ^Reader) {
b^ = {}
}
// reader_size returns the number of bytes in the backing buffer
reader_size :: proc(b: ^Reader) -> int {
return len(b.buf)
}
// reader_reset resets the read and write positions, and the error values
reader_reset :: proc(b: ^Reader, r: io.Reader) {
b.rd = r
b.r, b.w = 0, 0
@@ -257,7 +261,7 @@ reader_read_rune :: proc(b: ^Reader) -> (r: rune, size: int, err: io.Error) {
for b.r+utf8.UTF_MAX > b.w &&
!utf8.full_rune(b.buf[b.r:b.w]) &&
b.err == nil &&
b.w-b.w < len(b.buf) {
b.w-b.r < len(b.buf) {
_reader_read_new_chunk(b) or_return
}
+21 -7
View File
@@ -46,6 +46,7 @@ DEFAULT_MAX_SCAN_TOKEN_SIZE :: 1<<16
@(private)
_INIT_BUF_SIZE :: 4096
// Initializes a Scanner buffer an allocator `buf_allocator`
scanner_init :: proc(s: ^Scanner, r: io.Reader, buf_allocator := context.allocator) -> ^Scanner {
s.r = r
s.split = scan_lines
@@ -53,6 +54,8 @@ scanner_init :: proc(s: ^Scanner, r: io.Reader, buf_allocator := context.allocat
s.buf.allocator = buf_allocator
return s
}
// Initializes a Scanner buffer a user provided bytes buffer `buf`
scanner_init_with_buffer :: proc(s: ^Scanner, r: io.Reader, buf: []byte) -> ^Scanner {
s.r = r
s.split = scan_lines
@@ -75,24 +78,27 @@ scanner_error :: proc(s: ^Scanner) -> Scanner_Error {
return s._err
}
// Returns the most recent token created by scanner_scan.
// Returns the most recent token created by 'scan'.
// The underlying array may point to data that may be overwritten
// by another call to scanner_scan.
// by another call to 'scan'.
// Treat the returned value as if it is immutable.
scanner_bytes :: proc(s: ^Scanner) -> []byte {
return s.token
}
// Returns the most recent token created by scanner_scan.
// Returns the most recent token created by 'scan'.
// The underlying array may point to data that may be overwritten
// by another call to scanner_scan.
// by another call to 'scan'.
// Treat the returned value as if it is immutable.
scanner_text :: proc(s: ^Scanner) -> string {
return string(s.token)
}
// scanner_scan advances the scanner
scanner_scan :: proc(s: ^Scanner) -> bool {
// scanner_scan is an alias of scan
scanner_scan :: scan
// scan advances the Scanner
scan :: proc(s: ^Scanner) -> bool {
set_err :: proc(s: ^Scanner, err: Scanner_Error) {
switch s._err {
case nil, .EOF:
@@ -229,6 +235,7 @@ scanner_scan :: proc(s: ^Scanner) -> bool {
}
}
// scan_bytes is a splitting procedure that returns each byte as a token
scan_bytes :: proc(data: []byte, at_eof: bool) -> (advance: int, token: []byte, err: Scanner_Error, final_token: bool) {
if at_eof && len(data) == 0 {
return
@@ -236,6 +243,10 @@ scan_bytes :: proc(data: []byte, at_eof: bool) -> (advance: int, token: []byte,
return 1, data[0:1], nil, false
}
// scan_runes is a splitting procedure that returns each UTF-8 encoded rune as a token.
// The lsit of runes return is equivalent to that of iterating over a string in a 'for in' loop, meaning any
// erroneous UTF-8 encodings will be returned as U+FFFD. Unfortunately this means it is impossible for the "client"
// to know whether a U+FFFD is an expected replacement rune or an encoding of an error.
scan_runes :: proc(data: []byte, at_eof: bool) -> (advance: int, token: []byte, err: Scanner_Error, final_token: bool) {
if at_eof && len(data) == 0 {
return
@@ -264,7 +275,8 @@ scan_runes :: proc(data: []byte, at_eof: bool) -> (advance: int, token: []byte,
token = ERROR_RUNE
return
}
// scan_words is a splitting procedure that returns each Unicode-space-separated word of text, excluding the surrounded spaces.
// It will never return return an empty string.
scan_words :: proc(data: []byte, at_eof: bool) -> (advance: int, token: []byte, err: Scanner_Error, final_token: bool) {
is_space :: proc "contextless" (r: rune) -> bool {
switch r {
@@ -312,6 +324,8 @@ scan_words :: proc(data: []byte, at_eof: bool) -> (advance: int, token: []byte,
return
}
// scan_lines is a splitting procedure that returns each line of text stripping of any trailing newline and an optional preceding carriage return (\r?\n).
// A new line is allowed to be empty.
scan_lines :: proc(data: []byte, at_eof: bool) -> (advance: int, token: []byte, err: Scanner_Error, final_token: bool) {
trim_carriage_return :: proc "contextless" (data: []byte) -> []byte {
if len(data) > 0 && data[len(data)-1] == '\r' {
+2
View File
@@ -19,6 +19,7 @@ Writer :: struct {
}
// Initialized a Writer with an `allocator`
writer_init :: proc(b: ^Writer, wr: io.Writer, size: int = DEFAULT_BUF_SIZE, allocator := context.allocator) {
size := size
size = max(size, MIN_READ_BUFFER_SIZE)
@@ -27,6 +28,7 @@ writer_init :: proc(b: ^Writer, wr: io.Writer, size: int = DEFAULT_BUF_SIZE, all
b.buf = make([]byte, size, allocator)
}
// Initialized a Writer with a user provided buffer `buf`
writer_init_with_buf :: proc(b: ^Writer, wr: io.Writer, buf: []byte) {
writer_reset(b, wr)
b.buf_allocator = {}
+68 -38
View File
@@ -27,19 +27,19 @@ Read_Op :: enum i8 {
}
buffer_init :: proc(b: ^Buffer, buf: []byte) {
resize(&b.buf, len(buf))
buffer_init :: proc(b: ^Buffer, buf: []byte, loc := #caller_location) {
resize(&b.buf, len(buf), loc=loc)
copy(b.buf[:], buf)
}
buffer_init_string :: proc(b: ^Buffer, s: string) {
resize(&b.buf, len(s))
buffer_init_string :: proc(b: ^Buffer, s: string, loc := #caller_location) {
resize(&b.buf, len(s), loc=loc)
copy(b.buf[:], s)
}
buffer_init_allocator :: proc(b: ^Buffer, len, cap: int, allocator := context.allocator) {
buffer_init_allocator :: proc(b: ^Buffer, len, cap: int, allocator := context.allocator, loc := #caller_location) {
if b.buf == nil {
b.buf = make([dynamic]byte, len, cap, allocator)
b.buf = make([dynamic]byte, len, cap, allocator, loc)
return
}
@@ -96,28 +96,28 @@ buffer_truncate :: proc(b: ^Buffer, n: int) {
}
@(private)
_buffer_try_grow :: proc(b: ^Buffer, n: int) -> (int, bool) {
_buffer_try_grow :: proc(b: ^Buffer, n: int, loc := #caller_location) -> (int, bool) {
if l := len(b.buf); n <= cap(b.buf)-l {
resize(&b.buf, l+n)
resize(&b.buf, l+n, loc=loc)
return l, true
}
return 0, false
}
@(private)
_buffer_grow :: proc(b: ^Buffer, n: int) -> int {
_buffer_grow :: proc(b: ^Buffer, n: int, loc := #caller_location) -> int {
m := buffer_length(b)
if m == 0 && b.off != 0 {
buffer_reset(b)
}
if i, ok := _buffer_try_grow(b, n); ok {
if i, ok := _buffer_try_grow(b, n, loc=loc); ok {
return i
}
if b.buf == nil && n <= SMALL_BUFFER_SIZE {
// Fixes #2756 by preserving allocator if already set on Buffer via init_buffer_allocator
reserve(&b.buf, SMALL_BUFFER_SIZE)
resize(&b.buf, n)
reserve(&b.buf, SMALL_BUFFER_SIZE, loc=loc)
resize(&b.buf, n, loc=loc)
return 0
}
@@ -127,31 +127,34 @@ _buffer_grow :: proc(b: ^Buffer, n: int) -> int {
} else if c > max(int) - c - n {
panic("bytes.Buffer: too large")
} else {
resize(&b.buf, 2*c + n)
resize(&b.buf, 2*c + n, loc=loc)
copy(b.buf[:], b.buf[b.off:])
}
b.off = 0
resize(&b.buf, m+n)
resize(&b.buf, m+n, loc=loc)
return m
}
buffer_grow :: proc(b: ^Buffer, n: int) {
buffer_grow :: proc(b: ^Buffer, n: int, loc := #caller_location) {
if n < 0 {
panic("bytes.buffer_grow: negative count")
}
m := _buffer_grow(b, n)
resize(&b.buf, m)
m := _buffer_grow(b, n, loc=loc)
resize(&b.buf, m, loc=loc)
}
buffer_write_at :: proc(b: ^Buffer, p: []byte, offset: int) -> (n: int, err: io.Error) {
buffer_write_at :: proc(b: ^Buffer, p: []byte, offset: int, loc := #caller_location) -> (n: int, err: io.Error) {
if len(p) == 0 {
return 0, nil
}
b.last_read = .Invalid
if offset < 0 {
err = .Invalid_Offset
return
}
_, ok := _buffer_try_grow(b, offset+len(p))
_, ok := _buffer_try_grow(b, offset+len(p), loc=loc)
if !ok {
_ = _buffer_grow(b, offset+len(p))
_ = _buffer_grow(b, offset+len(p), loc=loc)
}
if len(b.buf) <= offset {
return 0, .Short_Write
@@ -160,47 +163,47 @@ buffer_write_at :: proc(b: ^Buffer, p: []byte, offset: int) -> (n: int, err: io.
}
buffer_write :: proc(b: ^Buffer, p: []byte) -> (n: int, err: io.Error) {
buffer_write :: proc(b: ^Buffer, p: []byte, loc := #caller_location) -> (n: int, err: io.Error) {
b.last_read = .Invalid
m, ok := _buffer_try_grow(b, len(p))
m, ok := _buffer_try_grow(b, len(p), loc=loc)
if !ok {
m = _buffer_grow(b, len(p))
m = _buffer_grow(b, len(p), loc=loc)
}
return copy(b.buf[m:], p), nil
}
buffer_write_ptr :: proc(b: ^Buffer, ptr: rawptr, size: int) -> (n: int, err: io.Error) {
return buffer_write(b, ([^]byte)(ptr)[:size])
buffer_write_ptr :: proc(b: ^Buffer, ptr: rawptr, size: int, loc := #caller_location) -> (n: int, err: io.Error) {
return buffer_write(b, ([^]byte)(ptr)[:size], loc=loc)
}
buffer_write_string :: proc(b: ^Buffer, s: string) -> (n: int, err: io.Error) {
buffer_write_string :: proc(b: ^Buffer, s: string, loc := #caller_location) -> (n: int, err: io.Error) {
b.last_read = .Invalid
m, ok := _buffer_try_grow(b, len(s))
m, ok := _buffer_try_grow(b, len(s), loc=loc)
if !ok {
m = _buffer_grow(b, len(s))
m = _buffer_grow(b, len(s), loc=loc)
}
return copy(b.buf[m:], s), nil
}
buffer_write_byte :: proc(b: ^Buffer, c: byte) -> io.Error {
buffer_write_byte :: proc(b: ^Buffer, c: byte, loc := #caller_location) -> io.Error {
b.last_read = .Invalid
m, ok := _buffer_try_grow(b, 1)
m, ok := _buffer_try_grow(b, 1, loc=loc)
if !ok {
m = _buffer_grow(b, 1)
m = _buffer_grow(b, 1, loc=loc)
}
b.buf[m] = c
return nil
}
buffer_write_rune :: proc(b: ^Buffer, r: rune) -> (n: int, err: io.Error) {
buffer_write_rune :: proc(b: ^Buffer, r: rune, loc := #caller_location) -> (n: int, err: io.Error) {
if r < utf8.RUNE_SELF {
buffer_write_byte(b, byte(r))
buffer_write_byte(b, byte(r), loc=loc)
return 1, nil
}
b.last_read = .Invalid
m, ok := _buffer_try_grow(b, utf8.UTF_MAX)
m, ok := _buffer_try_grow(b, utf8.UTF_MAX, loc=loc)
if !ok {
m = _buffer_grow(b, utf8.UTF_MAX)
m = _buffer_grow(b, utf8.UTF_MAX, loc=loc)
}
res: [4]byte
res, n = utf8.encode_rune(r)
@@ -246,10 +249,13 @@ buffer_read_ptr :: proc(b: ^Buffer, ptr: rawptr, size: int) -> (n: int, err: io.
}
buffer_read_at :: proc(b: ^Buffer, p: []byte, offset: int) -> (n: int, err: io.Error) {
if len(p) == 0 {
return 0, nil
}
b.last_read = .Invalid
if uint(offset) >= len(b.buf) {
err = .Invalid_Offset
err = .EOF
return
}
n = copy(p, b.buf[offset:])
@@ -310,6 +316,27 @@ buffer_unread_rune :: proc(b: ^Buffer) -> io.Error {
return nil
}
buffer_seek :: proc(b: ^Buffer, offset: i64, whence: io.Seek_From) -> (i64, io.Error) {
abs: i64
switch whence {
case .Start:
abs = offset
case .Current:
abs = i64(b.off) + offset
case .End:
abs = i64(len(b.buf)) + offset
case:
return 0, .Invalid_Whence
}
abs_int := int(abs)
if abs_int < 0 {
return 0, .Invalid_Offset
}
b.last_read = .Invalid
b.off = abs_int
return abs, nil
}
buffer_read_bytes :: proc(b: ^Buffer, delim: byte) -> (line: []byte, err: io.Error) {
i := index_byte(b.buf[b.off:], delim)
@@ -395,14 +422,17 @@ _buffer_proc :: proc(stream_data: rawptr, mode: io.Stream_Mode, p: []byte, offse
return io._i64_err(buffer_write(b, p))
case .Write_At:
return io._i64_err(buffer_write_at(b, p, int(offset)))
case .Seek:
n, err = buffer_seek(b, offset, whence)
return
case .Size:
n = i64(buffer_capacity(b))
n = i64(buffer_length(b))
return
case .Destroy:
buffer_destroy(b)
return
case .Query:
return io.query_utility({.Read, .Read_At, .Write, .Write_At, .Size, .Destroy})
return io.query_utility({.Read, .Read_At, .Write, .Write_At, .Seek, .Size, .Destroy, .Query})
}
return 0, .Empty
}
+317 -8
View File
@@ -1,9 +1,39 @@
// Procedures for manipulation of `[]byte` slices.
package bytes
import "base:intrinsics"
import "core:mem"
import "core:simd"
import "core:unicode"
import "core:unicode/utf8"
when ODIN_ARCH == .amd64 && intrinsics.has_target_feature("avx2") {
@(private)
SCANNER_INDICES_256 : simd.u8x32 : {
0, 1, 2, 3, 4, 5, 6, 7,
8, 9, 10, 11, 12, 13, 14, 15,
16, 17, 18, 19, 20, 21, 22, 23,
24, 25, 26, 27, 28, 29, 30, 31,
}
@(private)
SCANNER_SENTINEL_MAX_256: simd.u8x32 : u8(0x00)
@(private)
SCANNER_SENTINEL_MIN_256: simd.u8x32 : u8(0xff)
@(private)
SIMD_REG_SIZE_256 :: 32
}
@(private)
SCANNER_INDICES_128 : simd.u8x16 : {
0, 1, 2, 3, 4, 5, 6, 7,
8, 9, 10, 11, 12, 13, 14, 15,
}
@(private)
SCANNER_SENTINEL_MAX_128: simd.u8x16 : u8(0x00)
@(private)
SCANNER_SENTINEL_MIN_128: simd.u8x16 : u8(0xff)
@(private)
SIMD_REG_SIZE_128 :: 16
clone :: proc(s: []byte, allocator := context.allocator, loc := #caller_location) -> []byte {
c := make([]byte, len(s), allocator, loc)
copy(c, s)
@@ -105,8 +135,13 @@ equal_fold :: proc(u, v: []byte) -> bool {
return false
}
// TODO(bill): Unicode folding
r := unicode.simple_fold(sr)
for r != sr && r < tr {
r = unicode.simple_fold(sr)
}
if r == tr {
continue loop
}
return false
}
@@ -293,28 +328,277 @@ split_after_iterator :: proc(s: ^[]byte, sep: []byte) -> ([]byte, bool) {
return _split_iterator(s, sep, len(sep))
}
/*
Scan a slice of bytes for a specific byte.
index_byte :: proc(s: []byte, c: byte) -> int {
for i := 0; i < len(s); i += 1 {
This procedure safely handles slices of any length, including empty slices.
Inputs:
- data: A slice of bytes.
- c: The byte to search for.
Returns:
- index: The index of the byte `c`, or -1 if it was not found.
*/
index_byte :: proc "contextless" (s: []byte, c: byte) -> (index: int) #no_bounds_check {
i, l := 0, len(s)
// Guard against small strings. On modern systems, it is ALWAYS
// worth vectorizing assuming there is a hardware vector unit, and
// the data size is large enough.
if l < SIMD_REG_SIZE_128 {
for /**/; i < l; i += 1 {
if s[i] == c {
return i
}
}
return -1
}
c_vec: simd.u8x16 = c
when simd.HAS_HARDWARE_SIMD {
// Note: While this is something that could also logically take
// advantage of AVX512, the various downclocking and power
// consumption related woes make premature to have a dedicated
// code path.
when ODIN_ARCH == .amd64 && intrinsics.has_target_feature("avx2") {
c_vec_256: simd.u8x32 = c
s_vecs: [4]simd.u8x32 = ---
c_vecs: [4]simd.u8x32 = ---
m_vec: [4]u8 = ---
// Scan 128-byte chunks, using 256-bit SIMD.
for nr_blocks := l / (4 * SIMD_REG_SIZE_256); nr_blocks > 0; nr_blocks -= 1 {
#unroll for j in 0..<4 {
s_vecs[j] = intrinsics.unaligned_load(cast(^simd.u8x32)raw_data(s[i+j*SIMD_REG_SIZE_256:]))
c_vecs[j] = simd.lanes_eq(s_vecs[j], c_vec_256)
m_vec[j] = simd.reduce_or(c_vecs[j])
}
if m_vec[0] | m_vec[1] | m_vec[2] | m_vec[3] > 0 {
#unroll for j in 0..<4 {
if m_vec[j] > 0 {
sel := simd.select(c_vecs[j], SCANNER_INDICES_256, SCANNER_SENTINEL_MIN_256)
off := simd.reduce_min(sel)
return i + j * SIMD_REG_SIZE_256 + int(off)
}
}
}
i += 4 * SIMD_REG_SIZE_256
}
// Scan 64-byte chunks, using 256-bit SIMD.
for nr_blocks := (l - i) / (2 * SIMD_REG_SIZE_256); nr_blocks > 0; nr_blocks -= 1 {
#unroll for j in 0..<2 {
s_vecs[j] = intrinsics.unaligned_load(cast(^simd.u8x32)raw_data(s[i+j*SIMD_REG_SIZE_256:]))
c_vecs[j] = simd.lanes_eq(s_vecs[j], c_vec_256)
m_vec[j] = simd.reduce_or(c_vecs[j])
}
if m_vec[0] | m_vec[1] > 0 {
#unroll for j in 0..<2 {
if m_vec[j] > 0 {
sel := simd.select(c_vecs[j], SCANNER_INDICES_256, SCANNER_SENTINEL_MIN_256)
off := simd.reduce_min(sel)
return i + j * SIMD_REG_SIZE_256 + int(off)
}
}
}
i += 2 * SIMD_REG_SIZE_256
}
} else {
s_vecs: [4]simd.u8x16 = ---
c_vecs: [4]simd.u8x16 = ---
m_vecs: [4]u8 = ---
// Scan 64-byte chunks, using 128-bit SIMD.
for nr_blocks := l / (4 * SIMD_REG_SIZE_128); nr_blocks > 0; nr_blocks -= 1 {
#unroll for j in 0..<4 {
s_vecs[j]= intrinsics.unaligned_load(cast(^simd.u8x16)raw_data(s[i+j*SIMD_REG_SIZE_128:]))
c_vecs[j] = simd.lanes_eq(s_vecs[j], c_vec)
m_vecs[j] = simd.reduce_or(c_vecs[j])
}
if m_vecs[0] | m_vecs[1] | m_vecs[2] | m_vecs[3] > 0 {
#unroll for j in 0..<4 {
if m_vecs[j] > 0 {
sel := simd.select(c_vecs[j], SCANNER_INDICES_128, SCANNER_SENTINEL_MIN_128)
off := simd.reduce_min(sel)
return i + j * SIMD_REG_SIZE_128 + int(off)
}
}
}
i += 4 * SIMD_REG_SIZE_128
}
}
}
// Scan the remaining SIMD register sized chunks.
//
// Apparently LLVM does ok with 128-bit SWAR, so this path is also taken
// on potato targets. Scanning more at a time when LLVM is emulating SIMD
// likely does not buy much, as all that does is increase GP register
// pressure.
for nr_blocks := (l - i) / SIMD_REG_SIZE_128; nr_blocks > 0; nr_blocks -= 1 {
s0 := intrinsics.unaligned_load(cast(^simd.u8x16)raw_data(s[i:]))
c0 := simd.lanes_eq(s0, c_vec)
if simd.reduce_or(c0) > 0 {
sel := simd.select(c0, SCANNER_INDICES_128, SCANNER_SENTINEL_MIN_128)
off := simd.reduce_min(sel)
return i + int(off)
}
i += SIMD_REG_SIZE_128
}
// Scan serially for the remainder.
for /**/; i < l; i += 1 {
if s[i] == c {
return i
}
}
return -1
}
// Returns -1 if c is not present
last_index_byte :: proc(s: []byte, c: byte) -> int {
for i := len(s)-1; i >= 0; i -= 1 {
/*
Scan a slice of bytes for a specific byte, starting from the end and working
backwards to the start.
This procedure safely handles slices of any length, including empty slices.
Inputs:
- data: A slice of bytes.
- c: The byte to search for.
Returns:
- index: The index of the byte `c`, or -1 if it was not found.
*/
last_index_byte :: proc "contextless" (s: []byte, c: byte) -> int #no_bounds_check {
i := len(s)
// Guard against small strings. On modern systems, it is ALWAYS
// worth vectorizing assuming there is a hardware vector unit, and
// the data size is large enough.
if i < SIMD_REG_SIZE_128 {
#reverse for ch, j in s {
if ch == c {
return j
}
}
return -1
}
c_vec: simd.u8x16 = c
when simd.HAS_HARDWARE_SIMD {
// Note: While this is something that could also logically take
// advantage of AVX512, the various downclocking and power
// consumption related woes make premature to have a dedicated
// code path.
when ODIN_ARCH == .amd64 && intrinsics.has_target_feature("avx2") {
c_vec_256: simd.u8x32 = c
s_vecs: [4]simd.u8x32 = ---
c_vecs: [4]simd.u8x32 = ---
m_vec: [4]u8 = ---
// Scan 128-byte chunks, using 256-bit SIMD.
for i >= 4 * SIMD_REG_SIZE_256 {
i -= 4 * SIMD_REG_SIZE_256
#unroll for j in 0..<4 {
s_vecs[j] = intrinsics.unaligned_load(cast(^simd.u8x32)raw_data(s[i+j*SIMD_REG_SIZE_256:]))
c_vecs[j] = simd.lanes_eq(s_vecs[j], c_vec_256)
m_vec[j] = simd.reduce_or(c_vecs[j])
}
if m_vec[0] | m_vec[1] | m_vec[2] | m_vec[3] > 0 {
#unroll for j in 0..<4 {
if m_vec[3-j] > 0 {
sel := simd.select(c_vecs[3-j], SCANNER_INDICES_256, SCANNER_SENTINEL_MAX_256)
off := simd.reduce_max(sel)
return i + (3-j) * SIMD_REG_SIZE_256 + int(off)
}
}
}
}
// Scan 64-byte chunks, using 256-bit SIMD.
for i >= 2 * SIMD_REG_SIZE_256 {
i -= 2 * SIMD_REG_SIZE_256
#unroll for j in 0..<2 {
s_vecs[j] = intrinsics.unaligned_load(cast(^simd.u8x32)raw_data(s[i+j*SIMD_REG_SIZE_256:]))
c_vecs[j] = simd.lanes_eq(s_vecs[j], c_vec_256)
m_vec[j] = simd.reduce_or(c_vecs[j])
}
if m_vec[0] | m_vec[1] > 0 {
#unroll for j in 0..<2 {
if m_vec[1-j] > 0 {
sel := simd.select(c_vecs[1-j], SCANNER_INDICES_256, SCANNER_SENTINEL_MAX_256)
off := simd.reduce_max(sel)
return i + (1-j) * SIMD_REG_SIZE_256 + int(off)
}
}
}
}
} else {
s_vecs: [4]simd.u8x16 = ---
c_vecs: [4]simd.u8x16 = ---
m_vecs: [4]u8 = ---
// Scan 64-byte chunks, using 128-bit SIMD.
for i >= 4 * SIMD_REG_SIZE_128 {
i -= 4 * SIMD_REG_SIZE_128
#unroll for j in 0..<4 {
s_vecs[j] = intrinsics.unaligned_load(cast(^simd.u8x16)raw_data(s[i+j*SIMD_REG_SIZE_128:]))
c_vecs[j] = simd.lanes_eq(s_vecs[j], c_vec)
m_vecs[j] = simd.reduce_or(c_vecs[j])
}
if m_vecs[0] | m_vecs[1] | m_vecs[2] | m_vecs[3] > 0 {
#unroll for j in 0..<4 {
if m_vecs[3-j] > 0 {
sel := simd.select(c_vecs[3-j], SCANNER_INDICES_128, SCANNER_SENTINEL_MAX_128)
off := simd.reduce_max(sel)
return i + (3-j) * SIMD_REG_SIZE_128 + int(off)
}
}
}
}
}
}
// Scan the remaining SIMD register sized chunks.
//
// Apparently LLVM does ok with 128-bit SWAR, so this path is also taken
// on potato targets. Scanning more at a time when LLVM is emulating SIMD
// likely does not buy much, as all that does is increase GP register
// pressure.
for i >= SIMD_REG_SIZE_128 {
i -= SIMD_REG_SIZE_128
s0 := intrinsics.unaligned_load(cast(^simd.u8x16)raw_data(s[i:]))
c0 := simd.lanes_eq(s0, c_vec)
if simd.reduce_or(c0) > 0 {
sel := simd.select(c0, SCANNER_INDICES_128, SCANNER_SENTINEL_MAX_128)
off := simd.reduce_max(sel)
return i + int(off)
}
}
// Scan serially for the remainder.
for i > 0 {
i -= 1
if s[i] == c {
return i
}
}
return -1
}
@private PRIME_RABIN_KARP :: 16777619
index :: proc(s, substr: []byte) -> int {
@@ -1167,3 +1451,28 @@ fields_proc :: proc(s: []byte, f: proc(rune) -> bool, allocator := context.alloc
return subslices[:]
}
// alias returns true iff a and b have a non-zero length, and any part of
// a overlaps with b.
alias :: proc "contextless" (a, b: []byte) -> bool {
a_len, b_len := len(a), len(b)
if a_len == 0 || b_len == 0 {
return false
}
a_start, b_start := uintptr(raw_data(a)), uintptr(raw_data(b))
a_end, b_end := a_start + uintptr(a_len-1), b_start + uintptr(b_len-1)
return a_start <= b_end && b_start <= a_end
}
// alias_inexactly returns true iff a and b have a non-zero length,
// the base pointer of a and b are NOT equal, and any part of a overlaps
// with b (ie: `alias(a, b)` with an exception that returns false for
// `a == b`, `b = a[:len(a)-69]` and similar conditions).
alias_inexactly :: proc "contextless" (a, b: []byte) -> bool {
if raw_data(a) == raw_data(b) {
return false
}
return alias(a, b)
}
+9 -2
View File
@@ -9,10 +9,11 @@ Reader :: struct {
prev_rune: int, // previous reading index of rune or < 0
}
reader_init :: proc(r: ^Reader, s: []byte) {
reader_init :: proc(r: ^Reader, s: []byte) -> io.Stream {
r.s = s
r.i = 0
r.prev_rune = -1
return reader_to_stream(r)
}
reader_to_stream :: proc(r: ^Reader) -> (s: io.Stream) {
@@ -33,6 +34,9 @@ reader_size :: proc(r: ^Reader) -> i64 {
}
reader_read :: proc(r: ^Reader, p: []byte) -> (n: int, err: io.Error) {
if len(p) == 0 {
return 0, nil
}
if r.i >= i64(len(r.s)) {
return 0, .EOF
}
@@ -42,6 +46,9 @@ reader_read :: proc(r: ^Reader, p: []byte) -> (n: int, err: io.Error) {
return
}
reader_read_at :: proc(r: ^Reader, p: []byte, off: i64) -> (n: int, err: io.Error) {
if len(p) == 0 {
return 0, nil
}
if off < 0 {
return 0, .Invalid_Offset
}
@@ -97,7 +104,6 @@ reader_unread_rune :: proc(r: ^Reader) -> io.Error {
return nil
}
reader_seek :: proc(r: ^Reader, offset: i64, whence: io.Seek_From) -> (i64, io.Error) {
r.prev_rune = -1
abs: i64
switch whence {
case .Start:
@@ -114,6 +120,7 @@ reader_seek :: proc(r: ^Reader, offset: i64, whence: io.Seek_From) -> (i64, io.E
return 0, .Invalid_Offset
}
r.i = abs
r.prev_rune = -1
return abs, nil
}
reader_write_to :: proc(r: ^Reader, w: io.Writer) -> (n: i64, err: io.Error) {
+13 -1
View File
@@ -1,3 +1,4 @@
// Defines the basic types used by `C` programs for foreign function and data structure interop.
package c
import builtin "base:builtin"
@@ -48,7 +49,7 @@ int_least64_t :: builtin.i64
uint_least64_t :: builtin.u64
// Same on Windows, Linux, and FreeBSD
when ODIN_ARCH == .i386 || ODIN_ARCH == .amd64 {
when ODIN_ARCH == .i386 {
int_fast8_t :: builtin.i8
uint_fast8_t :: builtin.u8
int_fast16_t :: builtin.i32
@@ -57,6 +58,15 @@ when ODIN_ARCH == .i386 || ODIN_ARCH == .amd64 {
uint_fast32_t :: builtin.u32
int_fast64_t :: builtin.i64
uint_fast64_t :: builtin.u64
} else when ODIN_ARCH == .amd64 {
int_fast8_t :: builtin.i8
uint_fast8_t :: builtin.u8
int_fast16_t :: long
uint_fast16_t :: ulong
int_fast32_t :: long
uint_fast32_t :: ulong
int_fast64_t :: builtin.i64
uint_fast64_t :: builtin.u64
} else {
int_fast8_t :: builtin.i8
uint_fast8_t :: builtin.u8
@@ -114,3 +124,5 @@ CHAR_BIT :: 8
va_list :: struct #align(16) {
_: [4096]u8,
}
FILE :: struct {}
@@ -1,25 +0,0 @@
package c_frontend_preprocess
import "core:c/frontend/tokenizer"
const_expr :: proc(rest: ^^Token, tok: ^Token) -> i64 {
// TODO(bill): Handle const_expr correctly
// This is effectively a mini-parser
assert(rest != nil)
assert(tok != nil)
rest^ = tokenizer.new_eof(tok)
switch v in tok.val {
case i64:
return v
case f64:
return i64(v)
case string:
return 0
case []u16:
// TODO
case []u32:
// TODO
}
return 0
}
File diff suppressed because it is too large Load Diff
-154
View File
@@ -1,154 +0,0 @@
package c_frontend_preprocess
import "core:unicode/utf8"
unquote_char :: proc(str: string, quote: byte) -> (r: rune, multiple_bytes: bool, tail_string: string, success: bool) {
hex_to_int :: proc(c: byte) -> int {
switch c {
case '0'..='9': return int(c-'0')
case 'a'..='f': return int(c-'a')+10
case 'A'..='F': return int(c-'A')+10
}
return -1
}
w: int
if str[0] == quote && quote == '"' {
return
} else if str[0] >= 0x80 {
r, w = utf8.decode_rune_in_string(str)
return r, true, str[w:], true
} else if str[0] != '\\' {
return rune(str[0]), false, str[1:], true
}
if len(str) <= 1 {
return
}
s := str
c := s[1]
s = s[2:]
switch c {
case: r = rune(c)
case 'a': r = '\a'
case 'b': r = '\b'
case 'e': r = '\e'
case 'f': r = '\f'
case 'n': r = '\n'
case 'r': r = '\r'
case 't': r = '\t'
case 'v': r = '\v'
case '\\': r = '\\'
case '"': r = '"'
case '\'': r = '\''
case '0'..='7':
v := int(c-'0')
if len(s) < 2 {
return
}
for i in 0..<len(s) {
d := int(s[i]-'0')
if d < 0 || d > 7 {
return
}
v = (v<<3) | d
}
s = s[2:]
if v > 0xff {
return
}
r = rune(v)
case 'x', 'u', 'U':
count: int
switch c {
case 'x': count = 2
case 'u': count = 4
case 'U': count = 8
}
if len(s) < count {
return
}
for i in 0..<count {
d := hex_to_int(s[i])
if d < 0 {
return
}
r = (r<<4) | rune(d)
}
s = s[count:]
if c == 'x' {
break
}
if r > utf8.MAX_RUNE {
return
}
multiple_bytes = true
}
success = true
tail_string = s
return
}
unquote_string :: proc(lit: string, allocator := context.allocator) -> (res: string, allocated, success: bool) {
contains_rune :: proc(s: string, r: rune) -> int {
for c, offset in s {
if c == r {
return offset
}
}
return -1
}
assert(len(lit) >= 2)
s := lit
quote := '"'
if s == `""` {
return "", false, true
}
if contains_rune(s, '\n') >= 0 {
return s, false, false
}
if contains_rune(s, '\\') < 0 && contains_rune(s, quote) < 0 {
if quote == '"' {
return s, false, true
}
}
s = s[1:len(s)-1]
buf_len := 3*len(s) / 2
buf := make([]byte, buf_len, allocator)
offset := 0
for len(s) > 0 {
r, multiple_bytes, tail_string, ok := unquote_char(s, byte(quote))
if !ok {
delete(buf)
return s, false, false
}
s = tail_string
if r < 0x80 || !multiple_bytes {
buf[offset] = byte(r)
offset += 1
} else {
b, w := utf8.encode_rune(r)
copy(buf[offset:], b[:w])
offset += w
}
}
new_string := string(buf[:offset])
return new_string, true, true
}
-31
View File
@@ -1,31 +0,0 @@
/*
Example:
package demo
import tokenizer "core:c/frontend/tokenizer"
import preprocessor "core:c/frontend/preprocessor"
import "core:fmt"
main :: proc() {
t := &tokenizer.Tokenizer{};
tokenizer.init_defaults(t);
cpp := &preprocessor.Preprocessor{};
cpp.warn, cpp.err = t.warn, t.err;
preprocessor.init_lookup_tables(cpp);
preprocessor.init_default_macros(cpp);
cpp.include_paths = {"my/path/to/include"};
tok := tokenizer.tokenize_file(t, "the/source/file.c", 1);
tok = preprocessor.preprocess(cpp, tok);
if tok != nil {
for t := tok; t.kind != .EOF; t = t.next {
fmt.println(t.lit);
}
}
fmt.println("[Done]");
}
*/
package c_frontend_tokenizer
-68
View File
@@ -1,68 +0,0 @@
package c_frontend_tokenizer
// NOTE(bill): This is a really dumb approach for a hide set,
// but it's really simple and probably fast enough in practice
Hide_Set :: struct {
next: ^Hide_Set,
name: string,
}
new_hide_set :: proc(name: string) -> ^Hide_Set {
hs := new(Hide_Set)
hs.name = name
return hs
}
hide_set_contains :: proc(hs: ^Hide_Set, name: string) -> bool {
for h := hs; h != nil; h = h.next {
if h.name == name {
return true
}
}
return false
}
hide_set_union :: proc(a, b: ^Hide_Set) -> ^Hide_Set {
head: Hide_Set
curr := &head
for h := a; h != nil; h = h.next {
curr.next = new_hide_set(h.name)
curr = curr.next
}
curr.next = b
return head.next
}
hide_set_intersection :: proc(a, b: ^Hide_Set) -> ^Hide_Set {
head: Hide_Set
curr := &head
for h := a; h != nil; h = h.next {
if hide_set_contains(b, h.name) {
curr.next = new_hide_set(h.name)
curr = curr.next
}
}
return head.next
}
add_hide_set :: proc(tok: ^Token, hs: ^Hide_Set) -> ^Token {
head: Token
curr := &head
tok := tok
for ; tok != nil; tok = tok.next {
t := copy_token(tok)
t.hide_set = hide_set_union(t.hide_set, hs)
curr.next = t
curr = curr.next
}
return head.next
}
-169
View File
@@ -1,169 +0,0 @@
package c_frontend_tokenizer
Pos :: struct {
file: string,
line: int,
column: int,
offset: int,
}
Token_Kind :: enum {
Invalid,
Ident,
Punct,
Keyword,
Char,
String,
Number,
PP_Number,
Comment,
EOF,
}
File :: struct {
name: string,
id: int,
src: []byte,
display_name: string,
line_delta: int,
}
Token_Type_Hint :: enum u8 {
None,
Int,
Long,
Long_Long,
Unsigned_Int,
Unsigned_Long,
Unsigned_Long_Long,
Float,
Double,
Long_Double,
UTF_8,
UTF_16,
UTF_32,
UTF_Wide,
}
Token_Value :: union {
i64,
f64,
string,
[]u16,
[]u32,
}
Token :: struct {
kind: Token_Kind,
next: ^Token,
lit: string,
pos: Pos,
file: ^File,
line_delta: int,
at_bol: bool,
has_space: bool,
type_hint: Token_Type_Hint,
val: Token_Value,
prefix: string,
// Preprocessor values
hide_set: ^Hide_Set,
origin: ^Token,
}
Is_Keyword_Proc :: #type proc(tok: ^Token) -> bool
copy_token :: proc(tok: ^Token) -> ^Token {
t, _ := new_clone(tok^)
t.next = nil
return t
}
new_eof :: proc(tok: ^Token) -> ^Token {
t, _ := new_clone(tok^)
t.kind = .EOF
t.lit = ""
return t
}
default_is_keyword :: proc(tok: ^Token) -> bool {
if tok.kind == .Keyword {
return true
}
if len(tok.lit) > 0 {
return default_keyword_set[tok.lit]
}
return false
}
token_name := [Token_Kind]string {
.Invalid = "invalid",
.Ident = "ident",
.Punct = "punct",
.Keyword = "keyword",
.Char = "char",
.String = "string",
.Number = "number",
.PP_Number = "preprocessor number",
.Comment = "comment",
.EOF = "eof",
}
default_keyword_set := map[string]bool{
"auto" = true,
"break" = true,
"case" = true,
"char" = true,
"const" = true,
"continue" = true,
"default" = true,
"do" = true,
"double" = true,
"else" = true,
"enum" = true,
"extern" = true,
"float" = true,
"for" = true,
"goto" = true,
"if" = true,
"int" = true,
"long" = true,
"register" = true,
"restrict" = true,
"return" = true,
"short" = true,
"signed" = true,
"sizeof" = true,
"static" = true,
"struct" = true,
"switch" = true,
"typedef" = true,
"union" = true,
"unsigned" = true,
"void" = true,
"volatile" = true,
"while" = true,
"_Alignas" = true,
"_Alignof" = true,
"_Atomic" = true,
"_Bool" = true,
"_Generic" = true,
"_Noreturn" = true,
"_Thread_local" = true,
"__restrict" = true,
"typeof" = true,
"asm" = true,
"__restrict__" = true,
"__thread" = true,
"__attribute__" = true,
}

Some files were not shown because too many files have changed in this diff Show More