Commit Graph

101 Commits

Author SHA1 Message Date
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
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 1cf7a56ba7 General clean up of code 2025-01-01 15:13:46 +00: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
flysand7 3ed2ab6e2c [mem]: Adjust the docs for calc_padding_with_header 2024-09-14 10:18:51 +11:00
flysand7 f16ed256ea [mem]: Fix handling of default resize to check alignment 2024-09-11 08:00:27 +11:00
flysand7 1842cd6297 Fix typo
Co-authored-by: FourteenBrush <74827262+FourteenBrush@users.noreply.github.com>
2024-09-08 00:09:18 +11: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 2b9096517c [mem]: Code formatting 2024-09-07 09:20:56 +11:00
gingerBill 5fe0788cff Minimize code duplication in core:mem by using the base:runtime calls 2024-04-03 11:47:39 +01:00
gingerBill 3e7e779abf Replace core:* to base:* where appropriate 2024-01-28 22:18:51 +00:00
Laytan Laats 735cfcd290 Add formatting of bytes into the best unit of measurement 2023-09-01 19:17:07 +02:00
gingerBill 600c97cc0f Add missing Allocator_Error and @(require_results) to many procedures 2023-05-22 11:34:38 +01:00
hikari d904ae5191 Replaced opaque bit-shifts with readable constants for memory units 2022-12-24 08:27:15 +02:00
gingerBill 027ea587fc Unify mem and runtime logic 2022-08-26 16:45:40 +01:00
gingerBill d04f732e68 Add fmt:"s,0" to allow arrays and multi-pointers to be printed with NUL termination 2022-06-12 13:07:43 +01:00
gingerBill fb49841b1d Remove strings dependency from core:sys/windows 2022-06-02 13:02:16 +01:00
gingerBill 0cc67ff5e3 Add a return value to mem.zero_item and mem.zero_slice which is the same as the input 2022-05-17 22:42:37 +01:00
gingerBill ed4cb72b19 Merge pull request #1696 from Despacito696969/master
Fix for `slice_to_components` compilation error
2022-04-16 21:56:13 +01:00
hikari 698fcb7813 mem: replace size procedures with constants 2022-04-06 18:44:43 +03:00
Despacito696969 7f6c6945ae Fix for slice_to_components
Using `slice_to_components` wouldn't compile because `s.data` is type of `rawptr` and return type is `^T`
2022-04-05 20:17:47 +02:00
gingerBill 9f2d710c35 Change intrinsics.Atomic_Memory_Order fields to use Ada_Case rather than snake_case 2022-03-31 12:57:24 +01:00
gingerBill ba1930eb01 Update core to use new atomic intrinsics 2022-03-31 00:22:54 +01:00
Yawning Angel 672fc9fc4d core/mem: Add zero_explicit
This call is intended to provide the ability to securely scrub memory
without compiler interference, in a similar manner to explicit_bzero,
memset_s, SecureZeroMemory.

The approach taken is a volatile memset followed by a seqentially
consistent memory fence, to prevent the call from being optimized away
by DSE, and from being reordered.  An identical approach is currently
being used by the zeroize Rust crate, and is effective in practice.

LLVM IR output:
```
; Function Attrs: nounwind
define internal i8* @mem.zero_explicit(i8* %0, i64 %1) #0 {
decls:
  call void @llvm.memset.p0i8.i64(i8* %0, i8 0, i64 %1, i1 true)
  fence seq_cst
  ret i8* %0
}
```
2021-10-31 22:57:13 +00:00
gingerBill aaaddd03a6 Improve internal procedures 2021-10-25 01:28:06 +01:00
Jeroen van Rijn 1931e3147d Remove assert from mem.ptr_to_bytes. Fixes #1206 2021-10-05 14:18:48 +02:00
gingerBill bfc92d0aaf Make runtime.memset use int for the length from uint 2021-09-23 23:43:29 +01:00
gingerBill ab85571ae6 Minor improvements to mem.odin 2021-09-11 16:33:05 +01:00
gingerBill b712c84afb Fix typo 2021-09-10 16:37:43 +01:00
gingerBill 9980f81062 Add other constants to c and libc 2021-09-10 16:14:39 +01:00
gingerBill 12af657369 Unify memset usage across platforms and core:c/libc 2021-09-10 15:59:14 +01:00
gingerBill 99df0f1b12 libc changes: unify c and libc types; Add [^]T where appropriate 2021-09-10 15:41:51 +01:00
gingerBill ca33cb990b Strip semicolons in core which were missing 2021-09-08 13:12:38 +01:00
gingerBill 3754af62d6 Correct "contextless" stuff in mem 2021-09-08 11:43:00 +01:00
gingerBill a9f4273514 Make many mem procedures "contextless" 2021-09-08 11:18:05 +01:00
gingerBill 720884e0f1 Strip even more semicolons if followed by a } or ) on the same line 2021-08-31 23:47:57 +01:00
gingerBill 251da264ed Remove unneeded semicolons from the core library 2021-08-31 22:21:13 +01:00
gingerBill 81623861c0 Correct mem.clone_slice 2021-08-23 14:33:54 +01:00
gingerBill d5bad374d9 Remove deprecated procedure slice_ptr_to_bytes 2021-08-22 12:55:57 +01:00
gingerBill 445ed9be2b Use multi-pointers when appropriate 2021-08-22 12:54:04 +01:00
gingerBill 2f5edebefa Rename mem.reinterpret to mem.reinterpret_copy 2021-08-20 10:19:30 +01:00
gingerBill b5cdb331b0 Add mem.reinterpret 2021-08-20 10:18:34 +01:00
Jeroen van Rijn 03862d1f48 Mark mem.slice_ptr_to_bytes as deprecated.
Use byte_slice instead.

We can't make it an alias *and* mark it as deprecated, regrettably:

```odin
byte_slice :: #force_inline proc "contextless" (data: rawptr, len: int) -> []byte {
    return transmute([]u8)Raw_Slice{data=data, len=max(len, 0)};
}
@(deprecated="use byte_slice")
slice_ptr_to_bytes :: byte_slice;

"mem.odin(145:1) Constant alias declarations cannot have attributes"
```
2021-05-06 13:23:17 +02:00
gingerBill e9b1d4f633 Fix #906 2021-04-20 10:34:41 +01:00
gingerBill f98c4d6837 Improve the Allocator interface to support returning Allocator_Error to allow for safer calls
Virtually all code (except for user-written custom allocators) should work as normal. Extra features will need to be added to make the current procedures support the `Allocator_Error` return value (akin to #optional_ok)
2021-04-19 12:31:31 +01:00