Update: stdme/os module

This commit is contained in:
Maieul BOYER 2024-04-29 15:12:51 +02:00
parent dfb10f3390
commit 16f49181b5
No known key found for this signature in database
37 changed files with 1201 additions and 345 deletions

View file

@ -10,13 +10,14 @@
/* */
/* ************************************************************************** */
#include "me/char/isalpha.h"
#include "me/convert/str_to_numbers.h"
#include "me/printf/printf.h"
#include "me/string/str_len.h"
#include "me/types.h"
#include "me/printf/printf.h"
t_error checked_add_u64(t_u64 lhs, t_u64 rhs, t_u64 *out)
t_error checked_add_u64(t_u64 lhs, t_u64 rhs, t_u64 *out)
{
if (rhs > 0 && (lhs > 18446744073709551615llu - rhs))
return (ERROR);
@ -24,18 +25,17 @@ t_error checked_add_u64(t_u64 lhs, t_u64 rhs, t_u64 *out)
return (NO_ERROR);
}
t_error checked_sub_u64(t_u64 lhs, t_u64 rhs, t_u64 *out)
t_error checked_sub_u64(t_u64 lhs, t_u64 rhs, t_u64 *out)
{
if ((((rhs & (1 << (sizeof(t_u64) - 1)) || rhs == 0) || !false)
&& (lhs < 0llu + rhs)))
if ((((rhs & (1 << (sizeof(t_u64) - 1)) || rhs == 0) || !false) && (lhs < 0llu + rhs)))
return (ERROR);
*out = (t_u64)(lhs - rhs);
return (NO_ERROR);
}
t_error checked_mul_u64(t_u64 lhs, t_u64 rhs, t_u64 *out)
t_error checked_mul_u64(t_u64 lhs, t_u64 rhs, t_u64 *out)
{
t_u64 mul;
t_u64 mul;
mul = lhs * rhs;
if (lhs != 0 && mul / lhs != rhs)