730d0682ee
Result: Add try_set_value_with_specific_error()
2022-12-18 16:30:09 +01:00
6389099808
UTF-8 part 2: Encoding wide-character strings into UTF-8
...
continuous-integration/drone/push Build is passing
We now have Utf8StringEncoder and Utf8Encoder (no state this time)
2022-12-18 14:34:50 +01:00
9c1c6bb320
Add wcslen()
...
I think this can go in CString.h, no need to create a separate CWChar.h or something
2022-12-18 14:33:13 +01:00
75ba14a3ad
Add UTF-8 decoder support!!
2022-12-18 13:04:40 +01:00
23d405bbda
Add an unreachable() macro function that panics if reached
2022-12-18 12:40:28 +01:00
e4b971f09c
Make LinkedList::prepend() also set the element as the last one if we have no elements
continuous-integration/drone/push Build is passing
2022-12-17 15:28:18 +01:00
f5de9c5589
LinkedList: Add a prepend() method
continuous-integration/drone/push Build is passing
2022-12-17 15:27:16 +01:00
c5220cbf64
LinkedList: Rename append_after to add_after
2022-12-17 15:27:00 +01:00
2bc6398d3e
TRY(): Call release_value() instead of expect_release_value()
continuous-integration/drone/push Build is passing
2022-12-17 15:15:27 +01:00
34c738116c
Result: Make some member functions const
2022-12-17 15:15:00 +01:00
90bd4a83c0
Result, Option: Move member initialization to constructors
2022-12-17 15:14:27 +01:00
ee6387e7b5
Refactor NumberParsing.cpp + a lot of comments
2022-12-17 15:00:19 +01:00
97cb57d521
Check for overflow/underflow in parse_signed_integer
continuous-integration/drone/push Build is passing
2022-12-17 14:42:56 +01:00
acb0ab1cd7
Use TypeTraits in Alignment.h to make static assertions more readable
continuous-integration/drone/push Build is passing
2022-12-17 13:50:27 +01:00
ace674e518
LinkedList: Make sure the contained type inherits from DoublyLinkedListNode<T>
2022-12-17 13:49:47 +01:00
2cbc9fa385
Add some nice TypeTraits
2022-12-17 13:48:55 +01:00
16954695dd
Tell the compiler that string_format is a printf-style function
continuous-integration/drone/push Build is passing
2022-12-17 12:45:26 +01:00
16e00bada0
Add comments to Format.h
continuous-integration/drone/push Build is passing
2022-12-17 12:43:29 +01:00
abbed13f27
Add a 'pure' variant of cstyle_format which is infallible
...
If we cannot fail to output, it doesn't make sense to propagate errors. So if you're SURE there are no errors, use pure_cstyle_format().
If, however, output can fail, use cstyle_format().
This has a drawback of adding quite a bit of code duplication to Format.cpp.
Some of it is dealt using templates, but some code still remains duplicate.
2022-12-17 12:38:22 +01:00
48fcb8734a
Give number parsing functions more meaningful names
2022-12-17 12:12:58 +01:00
cf3b2176f0
Implement OwnedStringView::from_string_literal
continuous-integration/drone/push Build is passing
2022-12-17 11:36:16 +01:00
14461c6fe8
Atomic: Add operators += and -=
2022-12-17 10:49:19 +01:00
a16f357ab9
Add an Atomic class
continuous-integration/drone/push Build is passing
2022-12-16 21:15:22 +01:00
da39ba33a9
Move OwnedStringView::operator[] out of line
2022-12-16 20:48:58 +01:00
59765aa334
Rename String.h -> CString.h
...
continuous-integration/drone/push Build is passing
Let's not confuse String.h with a managed string class, it's in fact the equivalent of the C stdlib's <string.h>
2022-12-16 20:40:04 +01:00
42a2c2af49
Add strdup()
2022-12-16 20:37:57 +01:00
e56075fb46
Use nothrow in raw_malloc
2022-12-16 20:36:43 +01:00
345e13965e
Add missing include
...
continuous-integration/drone/push Build is passing
No one was noticing because everyone using OwnedStringView included Result.h before it
2022-12-16 20:27:44 +01:00
4a6c59d519
Make all methods in OwnedStringView const
continuous-integration/drone/push Build is passing
2022-12-16 19:48:22 +01:00
814672c771
Remove some redundant error propagation
...
continuous-integration/drone/push Build is passing
Why can printing to the serial port or format onto a string fail?
Even if cstyle_format returns Result<usize>, we shouldn't always follow suit.
2022-12-16 18:32:29 +01:00
41b3c8adb2
Convert to_dynamic_unit to OwnedStringView and rename the old variant to to_dynamic_unit_cstr
continuous-integration/drone/push Build is passing
2022-12-16 18:18:24 +01:00
be22cf6267
Introduce OwnedStringView
...
A managed String which uses RAII to free its contents. It's not a proper string though, since it's read-only.
So it's a StringView... but an owned one.
Can't be copied automatically, must be either moved or copied manually by calling clone() on it.
2022-12-16 18:17:15 +01:00
d759058b80
Introduce std::nothrow
...
Let's make sure we explicitly tell new that we don't want exceptions
2022-12-16 18:14:48 +01:00
32c8869973
Option: Simplify release_value
...
This avoids copying + we don't need to destroy the item if we move it, since it either gets emptied by moving it or doesn't have anything to destroy.
2022-12-16 18:13:40 +01:00
19a4e2ab58
Result, Option: Make sure everything is properly moved
2022-12-16 18:11:17 +01:00
b9f3d3c349
Remove ENONE
...
continuous-integration/drone/pr Build is passing
If you want to return an error without meaning, use Option.
2022-12-08 16:09:33 +01:00
b6173e2b67
LinkedList: Return Option instead of ENONE if no value
2022-12-08 16:09:04 +01:00
406af68a54
Result: Use Option as backend
2022-12-08 16:08:18 +01:00
b58eba63f1
Add a new Option class which behaves like Result, but has no error number, just a value or no value
2022-12-08 16:08:02 +01:00
6cee208e62
Kernel: Enable -Wsign-conversion
...
continuous-integration/drone/push Build is passing
For real this time, turns out me, being dumb, added it to Luna instead of the kernel.
2022-12-08 15:09:32 +01:00
1d5d1daa57
Add scope guards
2022-12-08 14:56:11 +01:00
6de7753b4c
Add malloc wrappers
continuous-integration/drone/push Build is passing
2022-12-07 18:17:49 +01:00
757cee4693
Add accessors for when you're sure a linked list is not empty
2022-12-07 16:11:59 +00:00
8da5521273
Add a Stack convenience class
2022-12-07 16:11:59 +00:00
f65ed465c4
Bitmap: Fix crash by attempting to memset -1 bits (UINT64_MAX)
2022-12-07 16:11:59 +00:00
d3458f2f0f
Bitmap: short circuit on 0-byte clears
2022-12-07 16:11:59 +00:00
4fdd1d57f5
Make build-debug.sh also add debug symbols to luna
2022-12-07 16:11:59 +00:00
287c4ab060
Run clang-format
2022-12-07 16:11:59 +00:00
986aa01948
size_t -> usize
continuous-integration/drone/push Build is passing
2022-12-07 17:06:29 +01:00
beab3454b5
kernel: Enable -Wsign-conversion and -Wcast-align
continuous-integration/drone/push Build is passing
2022-12-07 11:47:46 +01:00
1badc40a4a
Run include-what-you-use everywhere
2022-12-07 11:40:02 +01:00
ee276a3a35
Add the nodiscard attribute to make and make_array
continuous-integration/drone/push Build is passing
2022-12-07 11:01:45 +01:00
8598b1e8fc
Replace the _noreturn macro with the C++ native attribute [[noreturn]]
continuous-integration/drone/push Build is passing
2022-12-06 19:40:35 +01:00
39b310b6b9
Make alignment a template parameter to help the compiler optimize
continuous-integration/drone/push Build is passing
2022-12-06 19:27:58 +01:00
b5c6ae253d
Make LinkedList a lot better
continuous-integration/drone/push Build is passing
2022-12-06 18:41:35 +01:00
d8f75f1d3c
LinkedList: Add an append_after() method
...
Can be used to append an item after another one instead of at the end of the list.
With doubly linked lists, this is extremely easy to achieve (O(1)).
2022-12-06 18:25:08 +01:00
146da13e43
LinkedList: Make sure to explicitly mark the first node's next and last nodes as nullptr
2022-12-06 18:23:19 +01:00
07e6ebd3cc
LinkedList: Fix nonnull_or_error
2022-12-06 18:22:45 +01:00
87fb195202
Add DoublyLinkedList data structure
continuous-integration/drone/push Build is passing
2022-12-06 17:37:43 +01:00
dd29156c85
Alloc: make() now takes variadic arguments, to forward to the constructor
2022-12-06 17:36:20 +01:00
eef74e2897
Add a generic error code (ENONE)
2022-12-06 17:35:38 +01:00
a021e7a309
Move make and destroy to luna
continuous-integration/drone/push Build is passing
2022-12-06 16:41:22 +01:00
1fa99f4f64
Make {add,sub,mul}_will_overflow more compiler-independent
continuous-integration/drone/push Build is passing
2022-12-06 15:53:06 +01:00
26b44e651d
Change safe_{sub,add,mul} so they perform the operation only once
continuous-integration/drone/push Build is passing
2022-12-06 15:47:59 +01:00
e91c04b1d1
luna: Introduce safe arithmetic operations, which return an error if an operation would overflow
2022-12-06 15:40:18 +01:00
1e3706ac01
Make ARCH_PAGE_SIZE and ARCH_TIMER_FREQ known at compile-time
2022-12-05 16:36:41 +01:00
7cc139c3f7
Make expect and check use unlikely
2022-12-05 13:35:33 +01:00
792642dd6f
MORE CONST
2022-12-05 12:58:59 +01:00
86a12f301e
Make value_byte a helper
2022-12-05 12:53:16 +01:00
004e13a5f3
Make bitmap methods const if not modifying the bitmap
2022-12-05 12:50:30 +01:00
5aa2d1fa18
Add a Bitmap class to provide common functionality and use that in the MemoryManager
2022-12-04 15:14:07 +01:00
b8239698db
Add descriptions in CMakeLists
2022-12-04 12:47:08 +01:00
c7ab6bc2d3
Reorganize the luna/ directory so that headers aren't in the top level include path
2022-12-04 12:42:43 +01:00
cdbed6970a
Result: Add expect_ variants of value() and release_value()
2022-12-04 12:32:34 +01:00
bb92480aa3
Add a variant of check() that accepts an error message
2022-12-04 12:19:17 +01:00
3740309427
Check for STRINGIZE_VALUE_OF before defining it
2022-12-03 17:18:16 +01:00
1d51935d43
Make Result able to return an error string
2022-11-30 17:10:43 +01:00
fc0779a2f9
Add a SystemError module for errno values :)
2022-11-30 17:10:30 +01:00
f8ed74fda5
Improve unit representation code
2022-11-30 14:41:35 +01:00
f1756e6f58
Add unit formatting
2022-11-30 12:42:11 +01:00
552186ad51
Add string_format and vstring_format
2022-11-30 12:36:21 +01:00
9934719f6b
Use a more reliable signed 64-bit type than "long"
2022-11-23 18:05:01 +01:00
3b2dc5db55
PlacementNew.h: Use Types.h
2022-11-23 17:22:16 +01:00
2df0bc4238
Convert one tiny type to Types.h in Format.cpp
2022-11-20 18:31:55 +01:00
459e1ed653
luna/String.h: Convert to Types.h
2022-11-20 18:29:23 +01:00
3815f9aa9f
Introduce an offset_ptr function to avoid quirky C pointer arithmetic
2022-11-20 15:12:18 +01:00
33876dcda4
Use _strto{i,u} in _atou and _atos
2022-11-20 09:28:17 +01:00
bde5de68ca
Simplify is_valid_digit_for_base by reaching out to parse_digit_unchecked
2022-11-20 09:24:21 +01:00
44f44aedca
Make _strtoi call _strtou, to deduplicate code
2022-11-19 22:52:08 +01:00
30a7d760ae
Move a few repeated lambdas into their own functions
2022-11-19 22:48:20 +01:00
83bcac7a16
Kernel: Introduce a timer interface
2022-11-19 20:01:01 +01:00
db3e34b2ba
Result: Add try_set_value()
...
This helper returns true if the Result contains a value, or false if it doesn't.
Additionally, if it has a value, it sets the passed reference to it.
2022-11-19 18:38:01 +01:00
83e6bd1322
Make the build system more platform-agnostic
2022-11-19 17:46:53 +01:00
8cae20a82c
Move __check_failed out of line so anyone can implement it
2022-11-19 17:20:10 +01:00
2b9bdf560e
Move include to .cpp file
2022-11-19 17:19:25 +01:00
b8c136eeb4
Make a common header for attribute shorthands
2022-11-19 17:18:51 +01:00
648bd3fb61
Switch format.h to use Result
2022-11-19 16:13:25 +01:00
31673c0ac9
Introduce format attribute
2022-11-19 15:53:58 +01:00
dadc3e570b
Move a few functions out of line
2022-11-19 15:43:09 +01:00
56c2ca3381
Add _strtoi and _strtou
2022-11-19 15:27:55 +01:00
bad856afe0
Add %p and %% to cstyle_format
2022-11-19 15:26:29 +01:00
88af7a915b
Start padding and alternate forms for integers
2022-11-19 13:59:06 +01:00
c48203997a
Move output_integer into a function that accepts value arguments
2022-11-19 13:21:21 +01:00
4ebf244d3b
Support printing some integers in output_integer
2022-11-19 13:15:13 +01:00
603ff46d8c
Add a format implementation
2022-11-19 12:30:36 +01:00
be2e915d0d
Use the standard names for ctype functions if inside moon or _LUNA_OVERRIDE_STDC is defined
2022-11-18 21:17:26 +01:00
1b3243a80c
Add ctype.h functions to the Luna library
2022-11-18 21:12:54 +01:00
860f13cd7e
Rename align_base to alignment
2022-11-18 18:02:38 +01:00
2e2656a02f
Add static assertions to constexpr functions
2022-11-18 17:59:19 +01:00
30ac95bcf8
Use usize/isize instead of (s)size_t
...
Since we're using Rust-style integer types already, why not go all in?
2022-11-16 20:30:34 +01:00
7fc5a6b753
Make kernel rodata and data not executable
2022-11-16 20:02:04 +01:00
c9feb11366
Introduce a check() method (like assert() but always on)
2022-11-15 19:36:50 +01:00
705c2747de
Add memory manager
2022-11-13 14:29:15 +01:00
6b95307b54
Add init
2022-11-13 12:20:53 +01:00
82c2381ac9
Serial printing!!
2022-11-13 10:30:10 +01:00
cf758fdfdc
Initial commit :)
2022-11-13 10:09:09 +01:00